Does R2 have a native API?

I see that it's compatible with the S3, but with additional features (? does not elaborate). I'm not sure what the Worker API is tbh. I'm just looking for the "canonical" API and a description of all endpoints available.
9 Replies
Chaika
Chaika•6mo ago
R2's S3 Extensions are documented here: https://developers.cloudflare.com/r2/api/s3/extensions/ All of the APIs with links to S3's Specs are here and what is supported: https://developers.cloudflare.com/r2/api/s3/api/
__dil__
__dil__OP•6mo ago
Thank you, I didn't understand correctly when I looked at the docs but now I see
Chaika
Chaika•6mo ago
The Worker API is what you can use in Cloudflare Workers, Cloudflare's serverless offering: https://developers.cloudflare.com/r2/api/workers/workers-api-reference/ It exposes a native object for your bucket when you bind to one with a few methods
__dil__
__dil__OP•6mo ago
oh so it's more to connect serverless workers with r2 storage?
Chaika
Chaika•6mo ago
it's for using Cloudflare Workers, Cloudflare's specific serverless offering, with R2
__dil__
__dil__OP•6mo ago
got it now this might be a stretch, but do you know if cloudflare has a rust crate for the R2 API? I imagine I could use the one for s3, but that wouldn't include the extensions I suppose (and it would contain many unsupported operations too)
Chaika
Chaika•6mo ago
The extensions are either just extra features done implicily, or through custom headers which most SDKs provide a way to add: https://developers.cloudflare.com/r2/examples/aws/custom-header
Cloudflare Docs
Configure custom headers · Cloudflare R2 docs
Some of R2’s extensions require setting a specific header when using them in the S3 compatible API. For some functionality you may want to set a …
Chaika
Chaika•6mo ago
so you'd just want to find some crate for s3 that allows you to override the endpoint and such. If there's an aws-sdk for it, probably close to all the ones for other languages which do have guides (and to answer your original question about a native api, unless you're in a worker you just want to use the S3 Compatiable API. There is an undocumented "native" api for r2 the dashboard uses for interacting with objects, but it's undocumented and has limits on upload size (300 mb), and could change at any time since it's undocumented)
__dil__
__dil__OP•6mo ago
Alright I think that answers all my questions for now. I really appreciate your help, thanks! 😄
Want results from more Discord servers?
Add your server