Get Object
client.r2.buckets.objects.get(stringobjectKey, ObjectGetParams { account_id, bucket_name, jurisdiction, 2 more } params, RequestOptionsoptions?): Response
GET/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
Retrieves an object from an R2 bucket. Returns the object body along with metadata headers.
For most workloads, we recommend using R2’s S3-compatible API or a Worker with an R2 binding instead.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
Parameters
Get Object
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const object = await client.r2.buckets.objects.get('path/to/my-object.txt', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
bucket_name: 'example-bucket',
});
console.log(object);
const content = await object.blob();
console.log(content);