Skip to content
Start here

List Buckets

client.r2.buckets.list(BucketListParams { account_id, cursor, direction, 5 more } params, RequestOptionsoptions?): BucketListResponse { buckets }
GET/accounts/{account_id}/r2/buckets

Lists all R2 buckets on your account.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Workers R2 Storage WriteWorkers R2 Storage Read
ParametersExpand Collapse
params: BucketListParams { account_id, cursor, direction, 5 more }
account_id: string

Path param: Account ID.

maxLength32
cursor?: string

Query param: Pagination cursor received during the last List Buckets call. R2 buckets are paginated using cursors instead of page numbers.

direction?: "asc" | "desc"

Query param: Direction to order buckets.

One of the following:
"asc"
"desc"
name_contains?: string

Query param: Bucket names to filter by. Only buckets with this phrase in their name will be returned.

order?: "name"

Query param: Field to order buckets by.

per_page?: number

Query param: Maximum number of buckets to return in a single call.

maximum1000
minimum1
start_after?: string

Query param: Bucket name to start searching after. Buckets are ordered lexicographically.

jurisdiction?: "default" | "eu" | "fedramp"

Header param: Jurisdiction where objects in this bucket are guaranteed to be stored.

One of the following:
"default"
"eu"
"fedramp"
ReturnsExpand Collapse
BucketListResponse { buckets }
buckets?: Array<Bucket { creation_date, jurisdiction, location, 2 more } >
creation_date?: string

Creation timestamp.

jurisdiction?: "default" | "eu" | "fedramp"

Jurisdiction where objects in this bucket are guaranteed to be stored.

One of the following:
"default"
"eu"
"fedramp"
location?: "apac" | "eeur" | "enam" | 3 more

Location of the bucket.

One of the following:
"apac"
"eeur"
"enam"
"weur"
"wnam"
"oc"
name?: string

Name of the bucket.

maxLength64
minLength3
storage_class?: "Standard" | "InfrequentAccess"

Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
"Standard"
"InfrequentAccess"

List Buckets

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const buckets = await client.r2.buckets.list({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });

console.log(buckets.buckets);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "buckets": [
      {
        "creation_date": "creation_date",
        "jurisdiction": "default",
        "location": "apac",
        "name": "example-bucket",
        "storage_class": "Standard"
      }
    ]
  },
  "success": true,
  "result_info": {
    "cursor": "1-JTdCJTIydiUyMiUzQTElMkMlMjJzdGFydEFmdGVyJTIyJTNBJTIyZGF2aWRwdWJsaWMlMjIlN0Q=",
    "per_page": 20
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "buckets": [
      {
        "creation_date": "creation_date",
        "jurisdiction": "default",
        "location": "apac",
        "name": "example-bucket",
        "storage_class": "Standard"
      }
    ]
  },
  "success": true,
  "result_info": {
    "cursor": "1-JTdCJTIydiUyMiUzQTElMkMlMjJzdGFydEFmdGVyJTIyJTNBJTIyZGF2aWRwdWJsaWMlMjIlN0Q=",
    "per_page": 20
  }
}