Tencent Cloud Ape SDK for Python
raw JSON → 3.0.1459 verified Sat May 09 auth: no python
Official Tencent Cloud SDK for the Ape (Application Performance Engine) service, providing APIs for application performance monitoring and management. Current version is 3.0.1459, with regular releases aligned to Tencent Cloud API updates.
pip install tencentcloud-sdk-python-ape Common errors
error ModuleNotFoundError: No module named 'tencentcloud.ape' ↓
cause Missing or incorrect import path. The package is `tencentcloud-sdk-python-ape`, but import uses `tencentcloud.ape`.
fix
Ensure package is installed:
pip install tencentcloud-sdk-python-ape. Import from tencentcloud.ape.v20200513. error TencentCloudSDKException: [TencentCloudSDKException] code: UnauthorizedOperation, message: not authenticated ↓
cause Missing or invalid API credentials (SecretId/SecretKey).
fix
Set environment variables TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY, or pass them directly to Credential.
error TypeError: __init__() missing 1 required positional argument: 'cred' ↓
cause Client instantiation missing credential object or using deprecated signature.
fix
Use
ApeClient(cred, region) where cred is a Credential instance. Warnings
breaking Versioned imports: `from tencentcloud.ape.v20200513 import ape_client` instead of `from tencentcloud.ape import ApeClient`. The latter is deprecated and may be removed. ↓
fix Use versioned import path including API version (e.g., v20200513).
deprecated Older SDK versions (pre-3.0) used a different credential pattern. The `Credential` class now requires secret ID and key directly, not a profile object. ↓
fix Update to `credential.Credential('id', 'key')` and ensure SDK >=3.0.
gotcha Environment variables `TENCENTCLOUD_SECRET_ID` and `TENCENTCLOUD_SECRET_KEY` are not automatically read; you must pass them explicitly or use `EnvCredential`. ↓
fix Use `os.environ.get(...)` or `credential.Credential()` with the values, or use `credential.EnvCredential()` for automatic env loading.
Imports
- ApeClient wrong
from tencentcloud.ape import ApeClientcorrectfrom tencentcloud.ape.v20200513 import ape_client - models wrong
import modelscorrectfrom tencentcloud.ape.v20200513 import models
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.ape.v20200513 import ape_client, models
try:
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = ape_client.ApeClient(cred, 'ap-guangzhou')
req = models.DescribeApeInstancesRequest()
resp = client.DescribeApeInstances(req)
print(resp.to_json_string())
except TencentCloudSDKException as e:
print(e)