List Objects
client.r2.buckets.objects.list(stringbucketName, ObjectListParams { account_id, cursor, delimiter, 4 more } params, RequestOptionsoptions?): CursorPagination<ObjectListResponse { custom_metadata, etag, http_metadata, 5 more } >
GET/accounts/{account_id}/r2/buckets/{bucket_name}/objects
Lists objects in an R2 bucket. Returns object metadata including key, size, etag, last modified date, HTTP metadata, and custom metadata.
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:
List Objects
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const objectListResponse of client.r2.buckets.objects.list('example-bucket', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
})) {
console.log(objectListResponse.custom_metadata);
}{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": [
{
"custom_metadata": {},
"etag": "d41d8cd98f00b204e9800998ecf8427e",
"http_metadata": {
"cacheControl": "max-age=3600",
"cacheExpiry": "2024-12-31T23:59:59Z",
"contentDisposition": "attachment; filename=\"example.jpg\"",
"contentEncoding": "gzip",
"contentLanguage": "en-US",
"contentType": "image/jpeg"
},
"key": "path/to/my-object.txt",
"last_modified": "2024-01-15T10:30:00Z",
"size": 1048576,
"ssec": false,
"storage_class": "Standard"
}
],
"success": true,
"result_info": {
"cursor": "eyJrZXkiOiJwYXRoL3RvL215LW9iamVjdC50eHQifQ==",
"delimited": [
"path/to/",
"another/path/"
],
"is_truncated": true,
"per_page": 20
}
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": [
{
"custom_metadata": {},
"etag": "d41d8cd98f00b204e9800998ecf8427e",
"http_metadata": {
"cacheControl": "max-age=3600",
"cacheExpiry": "2024-12-31T23:59:59Z",
"contentDisposition": "attachment; filename=\"example.jpg\"",
"contentEncoding": "gzip",
"contentLanguage": "en-US",
"contentType": "image/jpeg"
},
"key": "path/to/my-object.txt",
"last_modified": "2024-01-15T10:30:00Z",
"size": 1048576,
"ssec": false,
"storage_class": "Standard"
}
],
"success": true,
"result_info": {
"cursor": "eyJrZXkiOiJwYXRoL3RvL215LW9iamVjdC50eHQifQ==",
"delimited": [
"path/to/",
"another/path/"
],
"is_truncated": true,
"per_page": 20
}
}