https://github.com/backrunner/afdian-api
一个爱发电开发者API的简易包装
https://github.com/backrunner/afdian-api
Last synced: 2 months ago
JSON representation
一个爱发电开发者API的简易包装
- Host: GitHub
- URL: https://github.com/backrunner/afdian-api
- Owner: backrunner
- Created: 2021-10-06T16:36:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-19T19:31:51.000Z (over 4 years ago)
- Last Synced: 2025-09-22T01:54:19.588Z (9 months ago)
- Language: TypeScript
- Size: 213 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# 爱发电 API
这是一个爱发电开发者 API 的简易化包装,可以当作一个简单的 SDK 使用。
注意:该包仅支持 Node.js,请在服务器端使用。(正确做法也应该是从服务器端请求)
## 使用方法
### 0x00 安装
```bash
npm install afdian-api -S
```
支持 TypeScript,无需额外安装类型包。
### 0x01 引入到项目
以下是一个最小化的例子:
```js
// esm
import Afdian from 'afdian-api';
// cjs
const Afdian = require('afdian-api');
const afdian = new Afdian({
token: '',
userId: '',
});
```
### 0x02 使用 API
所有 API 都经过了基于 `node-fetch` 做的简单包装,方法将直接返回解析后的回包,没有做任何其他处理。
#### ping
ping(): Promise\
例子:
```js
const res = await afdian.ping();
```
#### queryOrder
queryOrder(page: number): Promise\
例子:
```js
const res = await afdian.queryOrder(1);
```
#### querySponsor
querySponsor(page: number): Promise\
例子:
```js
const res = await afdian.querySponsor(1);
```
## License
MIT