Overview
Welcome to Tencent Cloud Software Development Kit (SDK) 3.0, a companion tool for the TencentCloud 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 NODEJS developers to debug and access the APIs of Tencent Cloud products, this document describes the Tencent Cloud SDK for NODEJS and provides a simple example of using the SDK for the first time, helping you quickly get the SDK and start calling.
API Explore
API Explore provides various capabilities such as online call, signature verification, SDK code generation and quick API retrieval that significantly reduce the difficulty of using cloud APIs.
Dependent Environment
1. NODEJS version 7.10.1 or higher.
2. Activate the corresponding product in the Tencent Cloud Console. 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 NODEJS. Before using the TencentCloud 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 npm
Installing via npm, a NODEJS package management tool, is the recommended way to use the SDK for NODEJS. For more information on npm, see npm's official website. 1. Execute the following installation command:
npm install tencentcloud-sdk-nodejs-intl-en --save
2. Refer to the corresponding module code in your code. For details, see the example.
Example
const tencentcloud = require("../../../../tencentcloud-sdk-nodejs-intl-en");
const CvmClient = tencentcloud.cvm.v20170312.Client;
const models = tencentcloud.cvm.v20170312.Models;
const Credential = tencentcloud.common.Credential;
let cred = new Credential("secretId", "secretKey");
let client = new CvmClient(cred, "ap-shanghai");
let req = new models.DescribeZonesRequest();
client.DescribeZones(req, function(errMsg, response) {
if (errMsg) {
console.log(errMsg);
return;
}
console.log(response.to_json_string());
});
More Examples
You can find more detailed examples in the examples directory of the GitHub repository.
本页内容是否解决了您的问题?