ListBuckets - Amazon Simple Storage Service

ListBuckets

Note

This operation is not supported by directory buckets.

Returns a list of all buckets owned by the authenticated sender of the request. To use this operation, you must have the s3:ListAllMyBuckets permission.

For information about Amazon S3 buckets, see Creating, configuring, and working with Amazon S3 buckets.

Request Syntax

GET /?bucket-region=BucketRegion&continuation-token=ContinuationToken&max-buckets=MaxBuckets&prefix=Prefix HTTP/1.1 Host: s3.amazonaws.com

URI Request Parameters

The request uses the following URI parameters.

bucket-region

Limits the response to buckets that are located in the specified AWS Region. The AWS Region must be expressed according to the AWS Region code, such as us-west-2 for the US West (Oregon) Region. For a list of the valid values for all of the AWS Regions, see Regions and Endpoints.

Note

Requests made to a Regional endpoint that is different from the bucket-region parameter are not supported. For example, if you want to limit the response to your buckets in Region us-west-2, the request must be made to an endpoint in Region us-west-2.

continuation-token

ContinuationToken indicates to Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key. You can use this ContinuationToken for pagination of the list results.

Length Constraints: Minimum length of 0. Maximum length of 1024.

Required: No.

max-buckets

Maximum number of buckets to be returned in response. When the number is more than the count of buckets that are owned by an AWS account, return all the buckets in response.

Valid Range: Minimum value of 1. Maximum value of 1000.

prefix

Limits the response to bucket names that begin with the specified bucket name prefix.

Request Body

The request does not have a request body.

Response Syntax

HTTP/1.1 200 <?xml version="1.0" encoding="UTF-8"?> <ListAllMyBucketsResult> <Buckets> <Bucket> <BucketRegion>string</BucketRegion> <CreationDate>timestamp</CreationDate> <Name>string</Name> </Bucket> </Buckets> <Owner> <DisplayName>string</DisplayName> <ID>string</ID> </Owner> <ContinuationToken>string</ContinuationToken> <Prefix>string</Prefix> </ListAllMyBucketsResult>

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in XML format by the service.

ListAllMyBucketsResult

Root level tag for the ListAllMyBucketsResult parameters.

Required: Yes

Buckets

The list of buckets owned by the requester.

Type: Array of Bucket data types

ContinuationToken

ContinuationToken is included in the response when there are more buckets that can be listed with pagination. The next ListBuckets request to Amazon S3 can be continued with this ContinuationToken. ContinuationToken is obfuscated and is not a real bucket.

Type: String

Owner

The owner of the buckets listed.

Type: Owner data type

Prefix

If Prefix was sent with the request, it is included in the response.

All bucket names in the response begin with the specified bucket name prefix.

Type: String

Examples

Sample Request

The following request returns a list of all buckets of the sender.

HTTP/1.1 200 OK <ListAllMyBucketsResult> <Buckets> <Bucket> <CreationDate>2019-12-11T23:32:47+00:00</CreationDate> <Name>DOC-EXAMPLE-BUCKET</Name> </Bucket> <Bucket> <CreationDate>2019-11-10T23:32:13+00:00</CreationDate> <Name>DOC-EXAMPLE-BUCKET2</Name> </Bucket> </Buckets> <Owner> <DisplayName>Account+Name</DisplayName> <ID>AIDACKCEVSQ6C2EXAMPLE</ID> </Owner> </ListAllMyBucketsResult>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: