# @tencent-sdk/capi

> Tencent cloud api sdk

Latest version **2.0.3** (published 2021-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tencent-sdk/capi
pnpm add @tencent-sdk/capi
yarn add @tencent-sdk/capi
bun add @tencent-sdk/capi
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2021-07-22 |
| First published | 2019-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 50.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yugasun |
| Maintainers | yugasun |
| Keywords | tencent-clound, api |

## Links

- npm: https://www.npmjs.com/package/@tencent-sdk/capi
- Repository: https://github.com/yugasun/tencent-sdk
- Homepage: https://github.com/yugasun/tencent-sdk#readme
- Issues: https://github.com/yugasun/tencent-sdk/issues
- npm.io page: https://npm.io/package/@tencent-sdk/capi

## Dependencies (2)

- [got](https://npm.io/package/got.md) ^11.8.2
- [@tencent-sdk/common](https://npm.io/package/@tencent-sdk/common.md) 1.0.0

## Recent versions

- 2.0.3 (latest) — 2021-07-22
- 2.0.2 — 2021-07-15
- 2.0.1 — 2021-07-15
- 2.0.0 — 2021-07-01
- 1.1.8 — 2020-12-01
- 1.1.7 — 2020-11-30
- 1.1.6 — 2020-11-05
- 1.1.5 — 2020-10-13
- 1.1.4 — 2020-09-24
- 1.1.3 — 2020-09-24
- 1.1.2 — 2020-09-23
- 1.1.1 — 2020-09-23
- 1.1.0 — 2020-09-10
- 0.4.0 — 2020-09-10
- 1.0.2 — 2020-09-10
- … 15 more at https://npm.io/package/@tencent-sdk/capi/versions

## README

## 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:

```js
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

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

### `CapiOptions` for Capi Constructor

| Name            | Description                   | Type    | Required | Default          |
| --------------- | ----------------------------- | ------- | -------- | ---------------- |
| ServiceType     | tencent service type          | string  | true     | ''               |
| Region          | request region                | string  | true     | ap-guangzhou     |
| SecretId        | tencent account secret id     | string  | true     | ''               |
| SecretKey       | tencent account secret key    | string  | true     | ''               |
| Token           | tencent account token         | string  | false    | ''               |
| debug           | whether enable log debug info | boolean | false    | false            |
| host            | request host                  | string  | false    | false            |
| baseHost        | request domain                | string  | false    | 'api.qcloud.com' |
| path            | request path                  | string  | false    | '/'              |
| method          | request method                | string  | false    | 'POST'           |
| protocol        | request protocol              | string  | false    | 'https'          |
| SignatureMethod | request signature             | string  | false    | 'sha1'           |

### `RequestData` for reqeust method

| Name          | Description          | Type   | Required | Default      |
| ------------- | -------------------- | ------ | -------- | ------------ |
| Action        | api action           | string | true     | ''           |
| Version       | api version          | string | true     | '2018-03-21' |
| RequestClient | specify your service | string | false    | 'TSS-CAPI'   |
| [propName]    | left api parameters  | any    | false    | ''           |

### `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

---
_Source: https://npm.io/package/@tencent-sdk/capi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
