Socket
Socket
Sign inDemoInstall

@tencent-sdk/capi

Package Overview
Dependencies
33
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tencent-sdk/capi

Tencent cloud api sdk


Version published
Weekly downloads
105K
decreased by-15.03%
Maintainers
1
Install size
2.86 MB
Created
Weekly downloads
 

Package description

What is @tencent-sdk/capi?

@tencent-sdk/capi is an npm package that provides a client for interacting with Tencent Cloud's API Gateway. It allows developers to easily integrate Tencent Cloud services into their Node.js applications by providing a set of tools and methods for making API requests.

What are @tencent-sdk/capi's main functionalities?

Initialize the Client

This feature allows you to initialize the client with your Tencent Cloud credentials and region. This is the first step to start making API requests.

const { Capi } = require('@tencent-sdk/capi');
const client = new Capi({
  SecretId: 'your-secret-id',
  SecretKey: 'your-secret-key',
  Region: 'ap-guangzhou'
});

Make an API Request

This feature allows you to make an API request to Tencent Cloud. In this example, it requests a list of instances in the specified region.

client.request({
  Action: 'DescribeInstances',
  Version: '2017-03-12',
  Region: 'ap-guangzhou'
}).then(response => {
  console.log(response);
}).catch(error => {
  console.error(error);
});

Set Custom Endpoint

This feature allows you to set a custom endpoint for the API requests. This can be useful if you need to interact with a specific service or region.

client.setEndpoint('cvm.tencentcloudapi.com');

Other packages similar to @tencent-sdk/capi

Readme

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

Last updated on 22 Jul 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc