tencentcloud-sdk-nodejs-common
- Version 4.1.66
- Published
- 92 kB
- 8 dependencies
- Apache-2.0 license
Install
npm i tencentcloud-sdk-nodejs-common
yarn add tencentcloud-sdk-nodejs-common
pnpm add tencentcloud-sdk-nodejs-common
Overview
腾讯云 API NODEJS SDK
Index
Variables
Classes
Interfaces
Type Aliases
Variables
variable SUPPORT_LANGUAGE_LIST
const SUPPORT_LANGUAGE_LIST: string[];
Supported values for ClientProfile.language property
Classes
class AbstractClient
class AbstractClient {}
Abstract base client for Tencent Cloud SDK
This class provides common functionality for making API requests to Tencent Cloud services, including request signing, error handling, and response parsing.
constructor
constructor( endpoint: string, version: string, { credential, region, profile }: ClientConfig);
Constructs a new AbstractClient instance
Parameter endpoint
The service endpoint URL (e.g. "cvm.tencentcloudapi.com")
Parameter version
The API version of the service (e.g. "2017-03-12")
Parameter config
Configuration object containing:
Parameter
{Credential|DynamicCredential} config.credential - Credentials for authentication
Parameter
{string} [config.region] - The region of the service (e.g. "ap-shanghai")
Parameter
{ClientProfile} [config.profile={}] - Optional client configuration profile
Throws
{TencentCloudSDKHttpException} If invalid language is specified in profile
Example 1
const client = new AbstractClient( "cvm.tencentcloudapi.com", "2017-03-12", { credential: { secretId: process.env.secretId, secretKey: process.env.secretKey, }, region: "ap-shanghai", profile: {} } );
property apiVersion
apiVersion: string;
The API version of the service (e.g. "2017-03-12")
property credential
credential: Credential | DynamicCredential;
User's security credentials (SecretId, SecretKey, Token)
property endpoint
endpoint: string;
The service endpoint URL (e.g. "cvm.tencentcloudapi.com")
property path
path: string;
API request path (usually "/")
property profile
profile: ClientProfile;
Optional configuration instance
property region
region: string;
The region of the service (e.g. "ap-shanghai")
property sdkVersion
sdkVersion: string;
SDK version string
method getCredential
getCredential: () => Promise<Credential>;
Get credential information
Returns
{Promise} Promise that resolves with credential information
method request
request: ( action: string, req: any, options?: ResponseCallback | RequestOptions, cb?: ResponseCallback) => Promise<ResponseData>;
Make an API request to Tencent Cloud service
Parameter action
The API action name to call
Parameter req
The request payload/parameters
Parameter options
Either request options or callback function
Parameter cb
Optional callback function for async operation
Returns
{Promise} Promise that resolves with the API response data
Example 1
// Using promise client.request('DescribeInstances', {Limit: 10}) .then(data => console.log(data)) .catch(err => console.error(err));
// Using callback client.request('DescribeInstances', {Limit: 10}, (err, data) => { if (err) console.error(err); else console.log(data); });
// With options client.request('DescribeInstances', {Limit: 10}, {signal: abortController.signal}) .then(data => console.log(data)) .catch(err => console.error(err));
method requestOctetStream
requestOctetStream: ( action: string, req: any, options?: ResponseCallback | RequestOptions, cb?: ResponseCallback) => Promise<any>;
Make a request with octet-stream content type
Parameter action
API action name
Parameter req
Request data
Parameter options
Request options or callback
Parameter cb
Callback function
Returns
{Promise} Promise that resolves with response data
class CommonClient
class CommonClient extends AbstractClient {}
Common client class for Tencent Cloud SDK
You only need to install the tencentcloud-sdk-nodejs-common package to Make an API request to any product
See Also
Interfaces
interface ClientConfig
interface ClientConfig {}
Configuration type for initializing client object
property credential
credential: Credential | DynamicCredential;
Parameter credential
Authentication information
property profile
profile?: ClientProfile;
Parameter profile
Optional configuration instance Optional, can be skipped if no special requirements
property region
region?: string;
Parameter region
Product region Required for region-specific products (e.g. CVM), optional for non-region products (e.g. SMS)
interface ClientProfile
interface ClientProfile {}
Optional configuration instance
property httpProfile
httpProfile?: HttpProfile;
HTTP related options instance {HttpProfile} Optional
property language
language?: 'zh-CN' | 'en-US';
Language field attached to API requests {"zh-CN" | "en-US"} Optional
property signMethod
signMethod?: 'TC3-HMAC-SHA256' | 'HmacSHA256' | 'HmacSHA1';
Signature method (TC3-HMAC-SHA256 HmacSHA1 HmacSHA256) {string} Optional
interface Credential
interface Credential {}
Credential information class
property secretId
secretId?: string;
Tencent Cloud account secretId and secretKey Optional, mutually exclusive with token
property secretKey
secretKey?: string;
Tencent Cloud account secretKey Optional, mutually exclusive with token
property token
token?: string;
Tencent Cloud account token Optional, mutually exclusive with secretId
interface DynamicCredential
interface DynamicCredential {}
Dynamic credential information
method getCredential
getCredential: () => Promise<Credential>;
interface HttpProfile
interface HttpProfile {}
property agent
agent?: Agent;
Advanced request agent, e.g. new HttpsProxyAgent("http://127.0.0.1:8899")
Higher priority than proxy configuration
property endpoint
endpoint?: string;
The service endpoint URL (e.g. "cvm.tencentcloudapi.com") {string} Optional
property headers
headers?: Record<string, string>;
Custom headers, e.g. { "X-TC-TraceId": "ffe0c072-8a5d-4e17-8887-a8a60252abca" } {Record<string, string>} Optional
property protocol
protocol?: string;
Protocol, currently supports "https://" {string} Optional
property proxy
proxy?: string;
HTTP request proxy, e.g. "http://127.0.0.1:8899"
property reqMethod
reqMethod?: 'POST' | 'GET';
Request method {"POST" | "GET"} Optional
property reqTimeout
reqTimeout?: number;
Request timeout in seconds, default 60s {number} Optional
interface RequestOptions
interface RequestOptions extends Partial<Pick<HttpProfile, 'headers'>> {}
Options for HTTP requests
Type Aliases
type ResponseCallback
type ResponseCallback<TReuslt = any> = (error: string, rep: TReuslt) => void;
Callback function type for API responses TReuslt Type of the response data
Package Files (4)
Dependencies (8)
Dev Dependencies (18)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/tencentcloud-sdk-nodejs-common
.
- Markdown[](https://www.jsdocs.io/package/tencentcloud-sdk-nodejs-common)
- HTML<a href="https://www.jsdocs.io/package/tencentcloud-sdk-nodejs-common"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3897 ms. - Missing or incorrect documentation? Open an issue for this package.