• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Bucket-Related APIs
  5. GET Buckets

GET Buckets

API Description

You can use this API to obtain the bucket list. In the list, bucket names are displayed in lexicographical order.

Method Definition

ObsClient.listBuckets()

Request Parameter

None.

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

ListBucketsResponse

Response result of GET Buckets

Sample Code

try:
    resp = obsClient.listBuckets() 
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('name:', resp.body.owner.owner_id) 
        print('create_date:', resp.body.owner.owner_name) 
        index = 1 
        for bucket in resp.body.buckets: 
            print('bucket [' + str(index) + ']') 
            print('name:', bucket.name) 
            print('create_date:', bucket.create_date) 
            index += 1 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())