Socket
Socket
Sign inDemoInstall

@tencent-sdk/capi

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tencent-sdk/capi

Tencent cloud api sdk


Version published
Weekly downloads
108K
increased by7.6%
Maintainers
1
Weekly downloads
 
Created
Source

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'
[propName]left 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

Keywords

FAQs

Package last updated on 24 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc