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
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/
Thank you, I didn't understand correctly when I looked at the docs but now I see
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
oh so it's more to connect serverless workers with r2 storage?
it's for using Cloudflare Workers, Cloudflare's specific serverless offering, with R2
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)
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 …
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)
Alright I think that answers all my questions for now. I really appreciate your help, thanks! 😄