Cloud Storage

Buckets: list

Retrieves a list of buckets for a given project. Try it now or see an example.

The authenticated user must be a member of the project's team. 


HTTP request

GET https://www.googleapis.com/storage/v1/b


Parameter name Value Description
Required query parameters
project string A valid API project identifier.
Optional query parameters
maxResults unsigned integer Maximum number of buckets to return.
pageToken string A previously-returned page token representing part of the larger set of results to view.
prefix string Filter results to buckets whose names begin with this prefix.
projection string Set of properties to return. Defaults to noAcl.

Acceptable values are:
  • "full": Include all properties.
  • "noAcl": Omit acl and defaultObjectAcl properties.

Request body

Do not supply a request body with this method.


If successful, this method returns a response body with the following structure:

  "kind": "storage#buckets",
  "nextPageToken": string,
  "items": [
    buckets Resource
Property name Value Description Notes
kind string The kind of item this is. For lists of buckets, this is always storage#buckets.
nextPageToken string The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
items[] list The list of items.


Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).


Uses the Java client library.

Storage.Buckets.List listBuckets = storage.buckets().list("myproject");
Buckets buckets;
do {
  buckets = listBuckets.execute();
  for (Bucket bucket : buckets.getItems()) {
    // Do things!
} while (null != buckets.getNextPageToken());


Uses the Python client library.

fields_to_return = 'nextPageToken,items(name,location,timeCreated)'
req = client.buckets().list(
        fields=fields_to_return,  # optional
        maxResults=42)            # optional
resp = req.execute()
print json.dumps(resp, indent=2)

# If you have too many items to list in one request, list_next() will
# automatically handle paging with the pageToken. 
while req is not None:
    resp = req.execute()
    print json.dumps(resp, indent=2)
    req = client.buckets().list_next(req, resp)


Uses the Ruby client library.

# List all buckets in the project.
page_token = '' # An empty pageToken will be ignored.
puts 'List of buckets: '
until page_token.nil? do
  bucket_list_result = client.execute(
    api_method: storage.buckets.list,
    parameters: {projectId: PROJECTID, pageToken: page_token}
  puts bucket_list_result.data.items.map(&:id)
  page_token = bucket_list_result.next_page_token


Uses the Go client library.

// List all buckets in a project.
result, err := service.Buckets.List("PROJECT_ID").Do()

for _, item := range result.Items {

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.