Tencent Cloud Afc SDK
raw JSON → 3.0.1459 verified Sat May 09 auth: no python
Tencent Cloud Afc (Anti-Fraud Cloud) SDK for Python. Provides access to Tencent Cloud's anti-fraud services. Current version: 3.0.1459. Released approximately weekly as part of the Tencent Cloud Python SDK monorepo. Active development.
pip install tencentcloud-sdk-python-afc Common errors
error ModuleNotFoundError: No module named 'tencentcloud' ↓
cause Base 'tencentcloud-sdk-python' package not installed.
fix
Run: pip install tencentcloud-sdk-python-afc (it depends on the base package automatically)
error AttributeError: module 'tencentcloud.afc' has no attribute 'afc_client' ↓
cause Incorrect import path; missing versioned subpackage.
fix
Use: from tencentcloud.afc.v20200226 import afc_client
error tencentcloud.common.exception.TencentCloudSDKException: [TencentCloudSDKException] code: AuthFailure.SecretIdNotFound ↓
cause Invalid or missing secret ID/secret key.
fix
Set environment variables TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY, or pass credentials directly.
Warnings
gotcha SDK v3 uses versioned subpackages (e.g., v20200226). Older examples may reference 'afc_client' directly under 'tencentcloud.afc' which is incorrect. ↓
fix Use the full versioned import path: `from tencentcloud.afc.v20200226 import afc_client, models`
gotcha Region must be specified when creating the client. Default is 'ap-guangzhou'. Some services require a specific region; check Tencent Cloud documentation. ↓
fix Always pass a region string (e.g., 'ap-guangzhou', 'ap-beijing') to the client constructor.
breaking Request and response models changed in v3. v2-style direct dictionary access is deprecated. Use model attributes. ↓
fix Instantiate request models with keyword arguments: `req = models.QueryAntiFraudVipRequest(PhoneNumber='12345678901')` instead of dict assignment.
Imports
- AfcClient wrong
from tencentcloud.afc import AfcClientcorrectfrom tencentcloud.afc.v20200226 import afc_client - models wrong
from tencentcloud.afc import modelscorrectfrom tencentcloud.afc.v20200226 import models
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.afc.v20200226 import afc_client, models
try:
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID'),
os.environ.get('TENCENTCLOUD_SECRET_KEY')
)
client = afc_client.AfcClient(cred, 'ap-guangzhou')
req = models.QueryAntiFraudVipRequest()
req.PhoneNumber = '12345678901'
resp = client.QueryAntiFraudVip(req)
print(resp)
except Exception as e:
print(e)