This page shows you how to list the Cloud Storage buckets in a project, which are ordered in the list lexicographically by name.
Required permissions
Console
In order to complete this guide using the Google Cloud console, you must have the proper IAM permissions. If you did not create the project you want to access, you might need the project owner to give you a role that contains the necessary permissions.
For a list of permissions required for specific actions, see IAM permissions for the Google Cloud console.
For a list of relevant roles, see Cloud Storage roles. Alternatively, you can create a custom role that has specific, limited permissions.
Command line
In order to complete this guide using a command-line utility, you must have the proper IAM permissions. If you did not create the project you want to access, you might need the project owner to give you a role that contains the necessary permissions.
For a list of permissions required for specific actions, see IAM permissions for gsutil commands.
For a list of relevant roles, see Cloud Storage roles. Alternatively, you can create a custom role that has specific, limited permissions.
Client libraries
In order to complete this guide using the Cloud Storage client libraries, you must have the proper IAM permissions. If you did not create the project you want to access, you might need the project owner to give you a role that contains the necessary permissions.
Unless otherwise noted, client library requests are made through the JSON API and require permissions as listed in IAM permissions for JSON methods. To see which JSON API methods are invoked when you make requests using a client library, log the raw requests.
For a list of relevant IAM roles, see Cloud Storage roles. Alternatively, you can create a custom role that has specific, limited permissions.
REST APIs
JSON API
In order to complete this guide using the JSON API, you must have the proper IAM permissions. If you did not create the project you want to access, you might need the project owner to give you a role that contains the necessary permissions.
For a list of permissions required for specific actions, see IAM permissions for JSON methods.
For a list of relevant roles, see Cloud Storage roles. Alternatively, you can create a custom role that has specific, limited permissions.
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 to narrow the results in your list.
Command line
gcloud
Use the gcloud storage ls
command:
gcloud storage ls
The response looks like the following example:
gs://BUCKET_NAME1/ gs://BUCKET_NAME2/ gs://BUCKET_NAME3/ ...
gsutil
Use the gsutil ls
command:
gsutil 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.
For more information, see the
Cloud Storage C# API
reference documentation.
For more information, see the
Cloud Storage Go API
reference documentation.
For more information, see the
Cloud Storage Java API
reference documentation.
For more information, see the
Cloud Storage Node.js API
reference documentation.
For more information, see the
Cloud Storage PHP API
reference documentation.
For more information, see the
Cloud Storage Python API
reference documentation.
For more information, see the
Cloud Storage Ruby API
reference documentation.
C++
C#
Go
Java
Node.js
PHP
Python
Ruby
REST APIs
JSON API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials. For instructions, see API authentication.
Use
cURL
to call the JSON API with aGET
Service request:curl -X GET -H "Authorization: Bearer OAUTH2_TOKEN" \ "https://storage.googleapis.com/storage/v1/b?project=PROJECT_IDENTIFIER"
Where:
OAUTH2_TOKEN
is the access token you generated in Step 1.PROJECT_IDENTIFIER
is the ID or number of the project containing the buckets you want to list. For example,my-project
.
XML API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials. For instructions, see API authentication.
Use
cURL
to call the XML API with aGET
Service request:curl -X GET -H "Authorization: Bearer OAUTH2_TOKEN" \ -H "x-goog-project-id: PROJECT_ID" \ "https://storage.googleapis.com"
Where:
OAUTH2_TOKEN
is the access token you generated in Step 1.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 and metadata.
- List the objects in a bucket.
- Move or rename a bucket.
- Delete a bucket.
- Learn how to paginate results.