List Buckets
r2.buckets.list(BucketListParams**kwargs) -> BucketListResponse
GET/accounts/{account_id}/r2/buckets
Lists a page of R2 buckets in the account and selected jurisdiction. Use the returned cursor to retrieve the next page.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
Accepted Permissions (at least one required)
Parameters
cursor: Optional[str]
Pagination cursor received during the last List Buckets call. R2 buckets are paginated using cursors instead of page numbers.
name_contains: Optional[str]
Bucket names to filter by. Only buckets with this phrase in their name will be returned.
List Buckets
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
buckets = client.r2.buckets.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(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
}
}