tencentcloud-sdk-python
The official Python SDK for the Tencent Cloud API 3.0 platform, covering hundreds of cloud products.
Repository Health
Technical Analysis
tencentcloud-sdk-python is the official Tencent Cloud developer toolkit for Python, providing generated client code for the Cloud API 3.0 platform. It exposes a consistent request/response model for every Tencent Cloud product — from CVM compute and CLS logging to Hunyuan AI services — so you can call any endpoint with strongly-typed request objects and signed HTTPS requests.
The SDK handles TC3-HMAC-SHA256 request signing, credential management, retries, proxy configuration, and region disaster recovery out of the box. It supports both synchronous calls (via requests) and asynchronous calls (via httpx) across Python 2.7 and 3.6 through 3.12, letting teams integrate Tencent Cloud services into scripts, backends, and high-concurrency workloads.
What You Get
- Generated Python clients and typed request/response models for hundreds of Tencent Cloud products
- Automatic TC3-HMAC-SHA256 request signing and a full credential provider chain (env vars, config file, instance roles, STS, TKE OIDC)
- Both synchronous (requests) and asynchronous (httpx) client variants sharing the same API surface
- Built-in retries, region disaster recovery, proxy support, and configurable HTTP profiles
Common Use Cases
- Provisioning and managing Tencent Cloud compute, storage, and network resources from Python automation
- Calling Tencent Cloud AI services such as Hunyuan chat completions from backend applications
- Uploading logs to CLS or integrating other Tencent Cloud managed services into data pipelines
Under The Hood
Architecture
The SDK is organized as one package namespace per Tencent Cloud product (e.g. tencentcloud.cvm.v20170312), each exposing a versioned *Client class and a models module of request/response types. All clients inherit from tencentcloud/common/abstract_client.py (~623 lines), which centralizes endpoint resolution, TC3-HMAC-SHA256 signing, serialization via abstract_model.py, retry orchestration, and a circuit-breaker-driven region disaster-recovery mechanism. Credentials flow through a provider chain in credential.py that tries environment variables, profile files, CVM/instance roles, and TKE OIDC in order.
Tech Stack
Written in pure Python targeting 2.7 and 3.6–3.12. The synchronous path depends only on requests>=2.16.0; the optional async path (installed via the [async] extra) uses httpx>=0.22.0 and exposes parallel *_client_async modules. The vast majority of the codebase is auto-generated from the Cloud API service definitions, keeping it in lockstep with the platform.
Code Quality
The repo ships a tests/ tree split into unit and integration suites and is marked Production/Stable. Because product clients are code-generated, naming and structure are highly uniform across the hundreds of modules; the hand-written common layer concentrates the meaningful logic (signing, retries, credentials, circuit breaking) and carries the test coverage.
API Design
Every call follows the same predictable shape: build a credential, instantiate a product client, populate a typed request object, then invoke the matching action method that returns a typed response. This uniformity makes the surface easy to learn once, though the per-endpoint request objects and explicit profiles make simple calls comparatively verbose. Extensive bilingual README examples and an examples/ directory cover common products and both sync and async styles.