Tencent Cloud Tag SDK for Python

raw JSON →
3.1.53 verified Sat May 09 auth: no python

Official Tencent Cloud SDK for managing Tag (Resource Tagging) services. Supports listing tags, creating/updating/deleting tag-key and tag-value pairs, and managing resource tags. Current version is 3.1.53, released Jan 2025. Follows monthly release cadence with the broader tencentcloud-sdk-python.

pip install tencentcloud-sdk-python-tag
error ModuleNotFoundError: No module named 'tencentcloud'
cause Missing base tencentcloud-sdk-python package (common) or not installed.
fix
Run pip install tencentcloud-sdk-python-common or pip install tencentcloud-sdk-python-tag which pulls it automatically.
error AttributeError: module 'tencentcloud.tag.v20180813.tag_client' has no attribute 'TagClient'
cause Incorrect import path; tried direct import of TagClient instead of the module.
fix
Use from tencentcloud.tag.v20180813 import tag_client and then tag_client.TagClient(...).
breaking In version 3.x, the SDK replaced old credential patterns. Use `tencentcloud.common.credential.Credential` instead of legacy `SecretId`/`SecretKey` dicts. Old patterns may raise AttributeError.
fix Import Credential from tencentcloud.common.credential and instantiate with secret_id and secret_key.
gotcha The client instance is `tag_client.TagClient`, not `TagClient` directly. Many users incorrectly try `from tencentcloud.tag.v20180813.tag_client import TagClient` which fails because TagClient is defined inside the module, not exported at the top level.
fix Use `from tencentcloud.tag.v20180813 import tag_client` and then `tag_client.TagClient(...)`.
gotcha API request objects are in `models` module. For example, `DescribeTagsRequest` must be imported from `tencentcloud.tag.v20180813.models` (or accessed as `models.DescribeTagsRequest`).
fix Import models: `from tencentcloud.tag.v20180813 import models`, then create requests with `req = models.DescribeTagsRequest()`.

Initialize client and list tags.

from tencentcloud.common import credential
from tencentcloud.tag.v20180813 import tag_client, models

# Replace with your credentials
cred = credential.Credential(
    secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
    secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = tag_client.TagClient(cred, 'ap-guangzhou')

# Describe tags
req = models.DescribeTagsRequest()
resp = client.DescribeTags(req)
print(resp.total_count)