All Projects → yuque → sdk

yuque / sdk

Licence: other
Node.js SDK for https://www.yuque.com/yuque/developer

Programming Languages

javascript
184084 projects - #8 most used programming language
HCL
1544 projects

Labels

Projects that are alternatives of or similar to sdk

yuquetopdf
从语雀文档生成规范的, 可打印版本的PDF文档
Stars: ✭ 21 (-85.71%)
Mutual labels:  yuque
language-grammars
Syntax highlighting for ABNF/BNF/EBNF, Yacc, and other language-related languages.
Stars: ✭ 14 (-90.48%)
Mutual labels:  lark
Lark
Lark is a parsing toolkit for Python, built with a focus on ergonomics, performance and modularity.
Stars: ✭ 2,916 (+1883.67%)
Mutual labels:  lark
simple-pyyuque
simple-pyyuque , unofficial python api for ant yuque
Stars: ✭ 21 (-85.71%)
Mutual labels:  lark
humanized opening hours
A parser for the opening_hours fields from OpenStreetMap
Stars: ✭ 22 (-85.03%)
Mutual labels:  lark
Web Clipper
For Notion,OneNote,Bear,Yuque,Joplin。Clip anything to anywhere
Stars: ✭ 3,645 (+2379.59%)
Mutual labels:  yuque
dique
🐦移动端语雀,你的掌上知识库
Stars: ✭ 64 (-56.46%)
Mutual labels:  yuque

Node SDK for yuque

NPM version build status Test coverage David deps Known Vulnerabilities NPM download

Install

npm i @yuque/sdk --save

Usage

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

/**
 * @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:

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

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

API

see Yuque API Docs 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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].