# @tswjs/open-platform-api

> Open api for https://tswjs.org

Latest version **2.0.8** (published 2022-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tswjs/open-platform-api
pnpm add @tswjs/open-platform-api
yarn add @tswjs/open-platform-api
bun add @tswjs/open-platform-api
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.8 |
| Published | 2022-08-11 |
| First published | 2020-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | maplemiao |
| Maintainers | tswjs-user, maplemiao, zack921 |

## Links

- npm: https://www.npmjs.com/package/@tswjs/open-platform-api
- Repository: https://github.com/tswjs/open-platform
- Homepage: https://github.com/tswjs/open-platform#readme
- Issues: https://github.com/tswjs/open-platform/issues
- npm.io page: https://npm.io/package/@tswjs/open-platform-api

## Dependencies (4)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [proxy-from-env](https://npm.io/package/proxy-from-env.md) ^1.1.0
- [http-proxy-agent](https://npm.io/package/http-proxy-agent.md) ^4.0.1
- [https-proxy-agent](https://npm.io/package/https-proxy-agent.md) ^5.0.0

## Recent versions

- 2.0.8 (latest) — 2022-08-11
- 2.0.7 — 2022-04-26
- 2.0.6 — 2022-02-23
- 2.0.6-alpha.0 — 2022-02-23
- 2.0.5 — 2022-02-22
- 2.0.4 — 2022-02-15
- 2.0.1 — 2022-01-25
- 2.0.0 — 2022-01-19
- 1.2.4 — 2021-09-13
- 1.2.2 — 2020-12-02
- 1.2.1 — 2020-09-28
- 1.2.0 — 2020-09-24
- 1.1.4 — 2020-09-21
- 1.1.3 — 2020-09-14
- 1.1.1 — 2020-08-04
- … 4 more at https://npm.io/package/@tswjs/open-platform-api/versions

## README

# open-platform-api
Open api for https://tswjs.org

## Install

`yarn add @tswjs/open-platform-api`

## Usage

```js
const { OpenApi } = require("@tswjs/open-platform-api");

const client = new OpenApi();

/**
 * 从开放平台同步代理名单
 */
client.updateProxyEnvByCloud().then(d => {
  console.log(d);
}, e => {
  console.error(e);
});

/**
 * 获取测试环境列表
 * @param {String} group 测试环境分组，默认获取全部环境
 */
client.listTestEnv().then(d => {
  console.log(d);
}, e => {
  console.error(e);
});

/**
 * 添加白名单
 * @param {string} uin 白名单号码 e.g 12345
 * @param {string} val 环境列表，或者是 alpha 只染色 e.g 127.0.0.1:8080 或者 alpha
 */
client.addTestUid(uin, val).then(d => {
  console.log(d);
}, e => {
  console.error(e);
});

/**
 * 清除测试环境对应白名单号码
 * @param {String[]} uinList 白名单号码列表
 */
client.removeTestUid(uinList).then(d => {
  console.log(d);
}, e => {
  console.error(e);
});
```

‼️ 重要

~~2.0版本以后，不再允许将开放平台申请的 `appid` 和 `appkey` 通过参数的形式透传到插件中。业务可以选择用合适的方式将这两个参数挂载到环境变量当中，对应形式如下且环境变量的名称不可更改：~~
废弃不合理特性，允许通过参数传入票据，无指定才会读取环境变量

```
appid => process.env.APP_ID
appkey =>  process.env.APP_KEY
```

---
_Source: https://npm.io/package/@tswjs/open-platform-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
