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
Client libraries
C++
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.
C#
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.
Go
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.
Java
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.
Node.js
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.
PHP
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.
Python
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.
Ruby
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.
Rust
The following sample lists all buckets. If a location is
temporarily unavailable, the service returns an error.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-07-22 UTC.