This page shows you how to list the Cloud Storage buckets in a project, which are ordered in the list lexicographically by name.
Before you begin
To get the permissions that you need to list buckets, ask your administrator to grant you the Storage Admin (roles/storage.admin) IAM role or the Viewer (roles/viewer) basic role on the project that contains the buckets you want to list.
For more information about granting roles for projects, see Manage access to projects.
The roles contain the storage.buckets.list permission, which is required to list buckets. You can also get this permission with custom roles.
List the buckets in a project
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
Buckets that are part of the selected project appear in the list.
Optionally, use filtering and sorting to limit and organize the results in your list.
Command line
-
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
In your development environment, run the
gcloud storage lscommand:gcloud storage ls
The response looks like the following example:
gs://BUCKET_NAME1/ gs://BUCKET_NAME2/ gs://BUCKET_NAME3/ ...
Client libraries
For more information, see the Cloud Storage C++ API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error. For more information, see the Cloud Storage C# API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error. For more information, see the Cloud Storage Go API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error. For more information, see the Cloud Storage Java API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error. For more information, see the Cloud Storage Node.js API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error. For more information, see the Cloud Storage PHP API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error. For more information, see the Cloud Storage Python API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error. For more information, see the Cloud Storage Ruby API reference documentation. To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries. The following sample lists all available buckets. If a location is temporarily unavailable, the response also includes the names of any buckets that can't be reached. The following sample lists all buckets. If a location is temporarily unavailable, the service returns an error.C++
C#
Go
Java
Node.js
PHP
Python
Ruby
REST APIs
JSON API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader.Use
cURLto call the JSON API with a request to list buckets:curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b?project=PROJECT_IDENTIFIER&returnPartialSuccess=RETURN_PARTIAL_SUCCESS_BOOLEAN"
Replace the following:
PROJECT_IDENTIFIER: the ID or number of the project containing the buckets you want to list. For example,my-project.RETURN_PARTIAL_SUCCESS_BOOLEAN: set this value totrueif you want to return a list of buckets even when some buckets can't be reached because a location is temporarily unavailable. If set tofalse, the request returns a list of buckets only if all locations can be reached, otherwise it returns an error. The default isfalse.
XML API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader.Use
cURLto call the XML API with aGETService request:curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-project-id: PROJECT_ID" \ "https://storage.googleapis.com"
Replace
PROJECT_IDwith the ID of the project containing the buckets you want to list. For example,my-project.
What's next
- Get information about a bucket's size.
- List the objects in a bucket.
- Move or rename a bucket.
- Delete a bucket.
- Learn how to paginate results.