Skip to content

Repository files navigation

Yuque logo

Yuque CLI

A scriptable toolkit for the Yuque (语雀) Open API —
search, read, write, and manage docs from scripts, pipelines, and agents.

CInpm versionnpm downloadsLicense

Quick Start · Commands · Scripting · Troubleshooting · 中文文档

Once authenticated, your knowledge base is one command away:

yuque search "canary release" --type doc # find that doc you half-remember
yuque doc get team/handbook onboarding > onboarding.md
yuque doc create team/notes --title "Weekly sync" --body-file weekly.md
yuque book list my-team --group --all --json | jq '.[].name'

Quick Start

1. Get a token — create one at Yuque Developer Settings. If you use a team token bound to a Yuque space, also note the space host (e.g. https://your-space.yuque.com) — you will pass it as --host or YUQUE_HOST.

2. Install and sign in:

npm install -g yuque-open-cli
export YUQUE_TOKEN=YOUR_TOKEN
yuque auth status
Run without installing (npx)
YUQUE_TOKEN=YOUR_TOKEN npx yuque-open-cli auth status

3. Start exploringyuque book list your-login, then yuque doc list <book>.

Configuration

SettingEnv var / CLI flagDescription
Token (required)YUQUE_TOKEN / --tokenPersonal or team Yuque API token (also reads YUQUE_PERSONAL_TOKEN as a compatibility fallback, e.g. shared with @yuque/mcp-server)
Host (optional)YUQUE_HOST / --hostSite or space host, e.g. https://your-space.yuque.com — required for space-bound team tokens and private deployments
Timeout (optional)YUQUE_TIMEOUT_MS / --timeoutAPI request timeout in milliseconds — default 30000

Flags win over env vars, so a one-off --token override always works. Site roots are normalized (/api/v2 is appended automatically); when unset, the host defaults to https://www.yuque.com.

Commands (33)

Each command maps to the Yuque OpenAPI — the mapping is locked by a contract test against the vendored spec.

CategoryCommandDescription
AuthpingVerify connectivity to the Yuque API
auth statusShow who you are signed in as
Useruser infoShow the authenticated user
user groups <user>List groups a user belongs to
Searchsearch <query>Search docs or books, with paging
Booksbook list <login>List books (知识库) of a user or --group
book get <book>Show a book by id or owner/slug
book create <login>Create a book
book update <book>Update name, slug, description, visibility, or TOC
book delete <book>Delete a book — asks for confirmation
Docsdoc list <book>List docs in a book, --all drains paging
doc get <book> <doc>Print a doc's markdown body; also takes a global <doc-id>, --meta for metadata
doc create <book>Create a doc from --body or --body-file
doc update <book> <doc>Update a doc's body or metadata
doc delete <book> <doc>Delete a doc — asks for confirmation
doc versions <doc-id>List a doc's version history
doc version <version-id>Show one version's content
Notesnote listList notes (小记), with --all support
note get <id>Show a note with its full content
note createCreate a note from --body or --body-file
note update <id>Update note source, HTML, abstract, and status
Boardsresource get <src>Read a structured board from a document
resource createCreate a mind map, flowchart, or architecture diagram
resource update <src>Update a board from text or JSON DSL
TOCtoc get <book>Print a book's table of contents as a tree
toc update <book>Append, prepend, edit, or remove a TOC node
Groupsgroup members <login>List members of a group
group member set <login> <user>Add a member or change their role
group member remove <login> <user>Remove a member — asks for confirmation
Statsstats group <login>Group-level statistics
stats members <login>Per-member statistics
stats books <login>Per-book statistics
stats docs <login>Per-doc statistics

Books (知识库) accept either a numeric id or an owner/slug namespace everywhere. For data-table docs, doc get accepts --page and --page-size to page the content. Run yuque <command> --help for all flags.

Output & scripting

Human-readable tables and records by default; add --json to any command for the full API payload:

yuque doc list team/handbook --all --json | jq -r '.[].slug'

Exit codes are stable, so scripts can branch on them:

CodeMeaning
0Success
1API or unknown error
2Usage error
3Authentication error
4Not found
5Rate limited

Colors are disabled automatically when piping, or force-off with NO_COLOR=1. Rate-limited and transient errors are retried with backoff before failing.

Write access

create, update, and delete commands modify real content, and the CLI can do whatever your token can do. Destructive commands prompt for confirmation on a TTY and require --yes in scripts. Keep the token secret, and prefer a space-scoped team token (with YUQUE_HOST) when you only work within one space.

Troubleshooting

ErrorSolution
A Yuque API token is requiredSet YUQUE_TOKEN=YOUR_TOKEN or pass --token=YOUR_TOKEN
token invalid or expired (exit 3)Regenerate the token or fix YUQUE_TOKEN / --token
rate limited by the Yuque API (exit 5)The CLI retries automatically; slow down --all loops
the requested resource does not exist (exit 4)Check the book id / owner/slug namespace and the doc slug
npm command not foundInstall Node.js v20 or later

Development

git clone https://github.com/yuque/yuque-open-cli.git
cd yuque-open-cli
npm install
npm test# unit tests
npm run build # compile TypeScript
npm run test:e2e # build, then run the binary against a mock Yuque API
npm run dev -- --help # run from source

The command surface is pinned to spec/yuque-openapi.yaml by tests/spec-coverage.test.ts; npm run check is the merge gate (lint, formatting, type checking, coverage-enforced unit tests, one build, dist smoke, and functional e2e).

Links

License

MIT

About

Scriptable CLI toolkit for the Yuque (语雀) Open API — search, read, write, and manage docs from scripts, pipelines, and agents

Topics

Resources

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages