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 currently 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 ls
command: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 a local development environment.
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 a local development environment.
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 a local development environment.
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 a local development environment.
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 a local development environment.
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 a local development environment.
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 a local development environment.
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 a local development environment.
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
Authorization
header.Use
cURL
to 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"
Where
PROJECT_IDENTIFIER
is the ID or number of the project containing the buckets you want to list. For example,my-project
.
XML API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorization
header.Use
cURL
to call the XML API with aGET
Service request:curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-project-id: PROJECT_ID" \ "https://storage.googleapis.com"
Where
PROJECT_ID
is 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.