All Products
Search
Document Center

Object Storage Service:Query bucket information using OSS SDK for Python 1.0

Last Updated:Mar 20, 2026

Use get_bucket_info() to retrieve metadata about a bucket — including its region, storage class, creation date, endpoints, owner, access control list (ACL), data redundancy type, and access tracking status.

Prerequisites

Before you begin, ensure that you have:

Get bucket information

The following example retrieves bucket information using the China (Hangzhou) public endpoint. To use an internal endpoint instead, see Regions and endpoints.

To create an OSSClient instance using a custom domain name or Security Token Service (STS), see Initialization.
# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider

# Load access credentials from environment variables.
# Set OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET before running this example.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())

# Set the endpoint for the region where your bucket is located.
# Example: https://oss-cn-hangzhou.aliyuncs.com for China (Hangzhou).
endpoint = "https://oss-cn-hangzhou.aliyuncs.com"

# Set the region ID. Required for V4 signatures.
region = "cn-hangzhou"

# Replace yourBucketName with the name of your bucket.
bucket = oss2.Bucket(auth, endpoint, "yourBucketName", region=region)

# Retrieve bucket information.
bucket_info = bucket.get_bucket_info()

# Print individual fields from the response.
print("name: " + bucket_info.name)
print("storage class: " + bucket_info.storage_class)
print("creation date: " + bucket_info.creation_date)
print("intranet_endpoint: " + bucket_info.intranet_endpoint)
print("extranet_endpoint " + bucket_info.extranet_endpoint)
print("owner: " + bucket_info.owner.id)
print("grant: " + bucket_info.acl.grant)
print("data_redundancy_type:" + bucket_info.data_redundancy_type)
# access_monitor requires Python SDK 2.16.1 or later.
print("access_monitor:" + bucket_info.access_monitor)

Response fields

get_bucket_info() returns a GetBucketInfoResult object. The following fields are available:

FieldTypeDescription
namestringBucket name
storage_classstringStorage class of the bucket (for example, Standard, IA, Archive)
creation_datestringDate the bucket was created
intranet_endpointstringInternal endpoint for accessing the bucket from other Alibaba Cloud services in the same region
extranet_endpointstringPublic endpoint for accessing the bucket over the internet
owner.idstringAlibaba Cloud account ID of the bucket owner
acl.grantstringACL of the bucket (for example, private, public-read, public-read-write)
data_redundancy_typestringData redundancy type of the bucket (for example, LRS, ZRS)
access_monitorstringAccess tracking status. Requires Python SDK 2.16.1 or later.

References