Interact with Yuque (语雀) knowledge base platform via the Yuque Open API.
YUQUE_TOKEN)https://www.yuque.com/api/v2All API requests require an X-Auth-Token header with your Yuque token.
curl -s -H "X-Auth-Token: $YUQUE_TOKEN" https://www.yuque.com/api/v2/user
curl -s -H "X-Auth-Token: $YUQUE_TOKEN" https://www.yuque.com/api/v2/users/<login>/repos
curl -s -H "X-Auth-Token: $YUQUE_TOKEN" https://www.yuque.com/api/v2/repos/<namespace>/docs
curl -s -H "X-Auth-Token: $YUQUE_TOKEN" https://www.yuque.com/api/v2/repos/<namespace>/docs/<slug>
# Get HTML content
curl -s -H "X-Auth-Token: $YUQUE_TOKEN" https://www.yuque.com/api/v2/repos/<namespace>/docs/<slug>?raw=1
# Get Markdown content
curl -s -H "X-Auth-Token: $YUQUE_TOKEN" https://www.yuque.com/api/v2/repos/<namespace>/docs/<slug>?raw=1 | python scripts/parse_yuque.py --format md
curl -s -X POST \
-H "X-Auth-Token: $YUQUE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "Document Title", "body": "Document content in Markdown"}' \
https://www.yuque.com/api/v2/repos/<namespace>/docs
curl -s -X PUT \
-H "X-Auth-Token: $YUQUE_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "New Title", "body": "Updated content"}' \
https://www.yuque.com/api/v2/repos/<namespace>/docs/<id>
Yuque API doesn't have a direct search endpoint. Use list + filter approach:
# List all docs in a repo and filter by title
python scripts/search_yuque.py --namespace <namespace> --query "keyword"
username/repo-slugteamname/repo-slugAll API responses are JSON with this structure:
{
"data": { ... },
"meta": { ... }
}
Common HTTP status codes:
401: Unauthorized (check token)403: Forbidden (no permission)404: Resource not found429: Rate limited (wait and retry)Use the provided Python scripts for common operations:
scripts/yuque_cli.py - Full CLI for Yuque operationsscripts/parse_yuque.py - Parse Yuque HTML to Markdownscripts/search_yuque.py - Search documents in repositories共 1 个版本