Registry / aws / tencentcloud-sdk-python-cws

tencentcloud-sdk-python-cws

JSON →
library3.0.1459pypypi✓ verified 84d ago

The official Tencent Cloud SDK module for the CWS (Cloud Web Scanner) service. This package is part of the larger tencentcloud-sdk-python ecosystem, version 3.0.1459. It provides Python bindings for the CWS API, enabling management of web scanning tasks, site verification, and vulnerability detection. Released irregularly alongside the main SDK.

pip install tencentcloud-sdk-python-cws
INSTALL
IMPORT
SIG · TENCENTCLOUD-SDK-P
T
tencentcloud-sdk-python-cws
awspythonv3.0.1459
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CwsClient
from tencentcloud.cws.v20180312 import cws_client
from tencentcloud.cws import CwsClient
CwsClient is inside the versioned subpackage; direct import from 'cws' won't work.

Lists all registered web scanning sites. Requires credentials set as environment variables TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY.

import os from tencentcloud.common import credential from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException from tencentcloud.cws.v20180312 import cws_client, models try: cred = credential.Credential( os.environ.get('TENCENTCLOUD_SECRET_ID', ''), os.environ.get('TENCENTCLOUD_SECRET_KEY', '') ) client = cws_client.CwsClient(cred, 'ap-guangzhou') req = models.DescribeSitesRequest() resp = client.DescribeSites(req) print(resp.to_json_string()) except TencentCloudSDKException as e: print(e)
Debug
Known issues
gotchaThe module version (3.0.1459) corresponds to the SDK release, not the API version. The CWS API version is v20180312; do not confuse with the SDK version.
fix
Always use 'v20180312' in the import path for the current CWS API.
affects: all
breakingThe Credential object no longer accepts a 'secret_key' as positional arg after version 3.0.500. Use keyword arguments or Credential(secret_id, secret_key) is still fine (both positional). However, the optional 'token' parameter changed to 'sessionToken'.
fix
Use Credential(secret_id, secret_key) or Credential(secret_id, secret_key, sessionToken='...') for temporary keys.
affects: >=3.0.500
deprecatedThe method 'to_json_string()' on response objects is deprecated in favor of 'to_json(indent=None)'. While still present, it may be removed.
fix
Replace resp.to_json_string() with resp.to_json() or str(resp).
affects: >=3.0.1000
gotchaRegion parameter in client constructor must be a valid Tencent Cloud region string (e.g., 'ap-guangzhou'). An invalid region silently defaults to 'ap-guangzhou' but may cause obscure API errors.
fix
Explicitly set the region via environment variable TENCENTCLOUD_REGION or pass a known region string.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tencentcloud.cws'
Missing installation of the specific submodule tencentcloud-sdk-python-cws, or mistakenly thinking it's included in the base package.
fix
Run: pip install tencentcloud-sdk-python-cws
AttributeError: module 'tencentcloud.cws' has no attribute 'v20180312'
Incorrect import path; trying to import from tencentcloud.cws directly instead of the versioned subpackage.
fix
Use: from tencentcloud.cws.v20180312 import cws_client
tencentcloud.common.exception.tencent_cloud_sdk_exception.TencentCloudSDKException: [InvalidParameter] InvalidParameter
Missing or invalid credentials; either SecretId or SecretKey is empty or incorrect.
fix
Set environment variables TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY properly. For temporary keys, also set TENCENTCLOUD_TOKEN.
tencentcloud.common.exception.tencent_cloud_sdk_exception.TencentCloudSDKException: [UnauthorizedOperation] UnauthorizedOperation
The API key does not have permission to access CWS. Ensure the key is associated with a CAM policy granting CWS actions.
fix
Check CAM permissions in Tencent Cloud console, or use a key with full CWS access.
Upgrade
Version history
3.0.1459latest on PyPI · released Sep 15, 2025
Audit
Dependencies
tencentcloud-sdk-python-commonrequiredRequired for base client and credential handling.
Agent activity
31 hits · last 30 days
node
20
OpenAI (training)
1
Resources
tencentcloud-sdk-python-cws — pip install tencentcloud-sdk-python-cws · libregistry