Retrieve list of buckets in cluster using Python SDK

I’m attempting to retrieve a list of buckets in a cluster using the Python SDK, but so far can’t find out exactly how to get it…

I’m currently setting up a connection to my cluster using

cluster = Cluster('couchbase://localhost')
authenticator = PasswordAuthenticator('admin', 'password')

but I don’t see any way to list the buckets available on the cluster. Is there a way to do it, or am I stuck heading out to the CLI for that option?

Hi, I’m afraid you are correct that there isn’t a direct way to retrieve a list of buckets in a cluster in Python. We do store the list in the _buckets member variable as an implementation detail but this isn’t supposed to be used externally. The supported way would be to use the REST API:

However, I will add this feature for the next release, which should be in the next week or two. Here is the JIRA:

Many thanks,


Hi Ellis,

That sounds great, thank you for the swift action.

To extend on the question, is there a way to list production views on a bucket, or it that doable through the REST API as well?

Stefan Finseth

Hi, I’m not aware of such a function - you would need to use REST calls for that, I think, for now. These look like the relevant endpoints:

I see the request was committed to git and closed, do we have this updated in pip install of couchbase?

Hi, yes, it should be available in the latest Couchbase Python Client, version 2.5.5. Unfortunately. it looks like I forgot to update the docs index so it’s missing from those, but the method is documented:

Will raise a ticket to add it to the docs index. Hope that helps!


thank you @ellis.breen…I do have the Couchbase Python Client 2.5.5 installed but do not see the method ‘bucket_list’. please share the info once the index is updated.

Hi, it turns out the RST docs should autoindex the Admin class anyway - for some reason it was omitted from the uploaded docs (probably generated prior to the addition of the buckets_list method). I’ve just generated the docs with the buckets_list method documented, which should be here soon:

In the meantime here’s the snippet of docs:

class couchbase.Admin.BucketInfo:

Information about a bucket

name ()

Name of the bucket.
returns a str containing the bucket name.

couchbase.Admin.buckets_list ()

Retrieve the list of buckets from the server :return: An iterable of Admin.BucketInfo objects describing the buckets currently active on the cluster.

Hope that helps!