# @yuque/sdk

> Node SDK for yuque

Latest version **1.1.1** (published 2019-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @yuque/sdk
pnpm add @yuque/sdk
yarn add @yuque/sdk
bun add @yuque/sdk
```

## 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 | 1.1.1 |
| Published | 2019-04-16 |
| First published | 2019-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 3 |
| Unpacked size | 19 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 170 |
| Author | TZ |
| Maintainers | atian25, dead_horse, fengmk2 |

## Links

- npm: https://www.npmjs.com/package/@yuque/sdk
- Repository: https://github.com/yuque/sdk
- Issues: https://github.com/yuque/sdk/issues
- npm.io page: https://npm.io/package/@yuque/sdk

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [urllib](https://npm.io/package/urllib.md) ^2.33.1
- [extend2](https://npm.io/package/extend2.md) ^1.0.0

## Recent versions

- 1.1.1 (latest) — 2019-04-16
- 1.1.0 — 2019-04-11

## README

# ![](./logo.png)

Node SDK for [yuque](https://www.yuque.com/yuque/developer/api)

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![NPM download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/@yuque/sdk.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@yuque/sdk
[travis-image]: https://img.shields.io/travis/yuque/sdk.svg?style=flat-square
[travis-url]: https://travis-ci.org/yuque/sdk
[codecov-image]: https://codecov.io/gh/yuque/sdk/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/yuque/sdk
[david-image]: https://img.shields.io/david/yuque/sdk.svg?style=flat-square
[david-url]: https://david-dm.org/yuque/sdk
[snyk-image]: https://snyk.io/test/npm/@yuque/sdk/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/@yuque/sdk
[download-image]: https://img.shields.io/npm/dm/@yuque/sdk.svg?style=flat-square
[download-url]: https://npmjs.org/package/@yuque/sdk

## Install

```bash
npm i @yuque/sdk --save
```

## Usage

```js
const SDK = require('@yuque/sdk');
const client = new SDK({
  token: '<YOUR TOKEN>',
  // other options
});

const result = await client.users.get();
console.log(result);

// apis
const { users, groups, repos, docs } = client;
```

## Options

```js
/**
 * @param {Object} options - opts
 * @param {String} options.token - yuque token, https://www.yuque.com/settings/tokens
 * @param {String} [options.endpoint] - yuque endpoint
 * @param {String} [options.userAgent] - request user-agent
 * @param {Object} [options.requestOpts] - default request options of [urllib](https://www.npmjs.com/package/urllib)
 * @param {Function} [options.handler] - special how to handler response
 */
```

by default, will return `response.data.data`, you can custom it by `handler`:

```js
new SDK({
  handler(res) {
    // should handler error yourself
    if (res.status !== 200) {
      const err = new Error(res.data.message);
      /* istanbul ignore next */
      err.status = res.data.status || res.status;
      err.code = res.data.code;
      err.data = res;
      throw err;
    }
    // return whatever you want
    const { data, abilities } = res.data;
    return data;
  },
});
```

## Debug

```js
$ http_proxy=http://127.0.0.1:8888 TOKEN=<YOUR_TOKEN> npm test
```

## API

see [Yuque API Docs](https://www.yuque.com/yuque/developer/api) for more details.

### users

see the source.

### groups

see the source.

### repos

see the source.

### docs

see the source.

## TODO

- [ ] API docs
- [ ] JSDocs definition for result info
- [ ] add `d.ts` or refactor to TypeScript

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