2.0.3 • Published 3 years ago

@tencent-sdk/capi v2.0.3

Weekly downloads
425,979
License
MIT
Repository
github
Last release
3 years ago

Tencent Cound API

This is a basement api tool for all tencent cloud apis.

Usage

Capi is the only class for create a client request instance, and the instance only has one method request. You can use it like below:

import { Capi } from '@tencent-sdk/capi';

const client = new Capi({
  Region: 'ap-guangzhou',
  SecretId: 'Please input your SecretId',
  SecretKey: 'Please input your SecretKey',
  Token: 'Please input your Token',
  ServiceType: 'tmt',
});
try {
  const res = await client.request(
    {
      Action: 'TextTranslate',
      Version: '2018-03-21',
      SourceText: 'hello',
      Source: 'auto',
      Target: 'zh',
      ProjectId: 0,
    },
    {
      debug: true,
      host: 'tmt.tencentcloudapi.com',
    },
  );
  console.log('res', res);
} catch (e) {
  console.log(e);
}

This is a demo for using Tencent Machine Translator.

Options

const client = new Capi(CapiOptions);
client.request(RequestData, RequestOptions, isV3);

CapiOptions for Capi Constructor

NameDescriptionTypeRequiredDefault
ServiceTypetencent service typestringtrue''
Regionrequest regionstringtrueap-guangzhou
SecretIdtencent account secret idstringtrue''
SecretKeytencent account secret keystringtrue''
Tokentencent account tokenstringfalse''
debugwhether enable log debug infobooleanfalsefalse
hostrequest hoststringfalsefalse
baseHostrequest domainstringfalse'api.qcloud.com'
pathrequest pathstringfalse'/'
methodrequest methodstringfalse'POST'
protocolrequest protocolstringfalse'https'
SignatureMethodrequest signaturestringfalse'sha1'

RequestData for reqeust method

NameDescriptionTypeRequiredDefault
Actionapi actionstringtrue''
Versionapi versionstringtrue'2018-03-21'
RequestClientspecify your servicestringfalse'TSS-CAPI'
propNameleft api parametersanyfalse''

RequestOptions for reqeust method

It is a copy from CapiOptions, if you set this, you can rewrite the properties in CapiOptions.

isV3 for request method

isV3 is used to specify to use version for authentication.

true: using TC3-HMAC-SHA256
false: using HmacSHA256 or Sha1

License

MIT