Overview
Welcome to Tencent Cloud Software Development Kit (SDK) 3.0, a companion tool for the Cloud API 3.0 platform. Currently, it supports products such as CVM, VPC and CBS. All cloud services and products will be integrated here for access in the future. The new version of SDK is unified and features the same SDK usage, API call methods, error codes and return packet formats for different languages.
To make it easier for Python developers to debug and access the APIs of Tencent Cloud products, this document describes the Tencent Cloud SDK for Python and provides a simple example of using the SDK for the first time, helping you quickly get the SDK and start calling.
Dependent Environment
1. Dependent environment: Python version 2.7 to 3.6.
3. Get the SecretID, SecretKey and call address (endpoint). The general format of endpoint is *.tencentcloudapi.com. For example, the call address of CVM is cvm.tencentcloudapi.com. For details, see the documentation of the specific product.
Installation
Obtain the security credentials before installing the SDK for Python. Before using the Cloud API for the first time, you need to first apply for security credentials in the Tencent Cloud Console, including SecretID and SecretKey. SecretID is used to identify the API caller, while SecretKey is used to encrypt the signature string and verify it on the server. You must keep the SecretKey private and avoid disclosure.
Installing via Pip (Recommended)
You can install the Tencent Cloud API SDK for Python into your project via Pip. If you haven't installed Pip in your project environment yet, install it first by following the instruction at Pip's official website.
To install via Pip, execute the following command in command line: pip install tencentcloud-sdk-python-intl-en
Example
Take the API for querying available zones as an example:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cvm.v20170312 import cvm_client, models
try:
cred = credential.Credential("secretId", "secretKey")
client = cvm_client.CvmClient(cred, "ap-shanghai")
req = models.DescribeZonesRequest()
resp = client.DescribeZones(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
More Examples
You can find more detailed examples in the examples directory of the GitHub repository.
本页内容是否解决了您的问题?