✨
简介
SiYuan API
原始描述
思源笔记 - SiYuan API Skill,支持笔记本、文档、块、资源、数据库/属性视图和 SQL 操作。Local-only SiYuan API integration for notebooks, documents, blocks, assets, database/attribute views, and SQL operations.
通过你的 Agent 添加
安装目录:siyuan-api/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
Claude Code~/.claude/skills/siyuan-api/
Codex CLI~/.codex/skills/siyuan-api/
DeepSeek Harness~/.agents/skills/siyuan-api/
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: siyuan-api description: Local SiYuan API integration for notebook/document/block/asset operations and SQL search. Uses only local HTTP endpoints and environment-based token auth. homepage: https://github.com/siyuan-note/siyuan metadata: openclaw: requires: env: SIYUAN_API_TOKEN: description: SiYuan API token from Settings > About required: true SIYUAN_API_URL: description: SiYuan API base URL. Default is http://127.0.0.1:6806 required: false
SiYuan Skill
本技能用于调用本地运行的 SiYuan HTTP API,支持笔记本、文档、块、资源、SQL 查询等常见操作。 它只描述调用规范和示例,不包含可执行安装脚本或第三方依赖。
Security Scope
- Only call local SiYuan endpoint (
127.0.0.1,localhost, or user-provided local URL). - Do not send requests to third-party internet endpoints.
- Never hardcode or print
SIYUAN_API_TOKENin logs. - This skill has read/write authority over your SiYuan notes. Use only in trusted local environments.
Configuration
SIYUAN_API_TOKEN(required): from SiYuanSettings > About.SIYUAN_API_URL(optional): defaults tohttp://127.0.0.1:6806.
Install and Use in OpenClaw
Command line
# Install from ClawHub into your OpenClaw workspace
npx clawhub install siyuan-api --workdir ~/.openclaw/workspace
# Verify the skill is available
openclaw skills info siyuan-api
openclaw skills check
In chat dialog
Tell OpenClaw to use this skill explicitly, for example:
Use the siyuan-api skill to list all notebooks in my local SiYuan.使用 siyuan-api skill,帮我创建一篇 Markdown 文档到指定笔记本。
Typical Use Cases
- Create, rename, and remove notebooks
- Create documents from Markdown
- Insert, append, update, move, and delete blocks
- Upload assets
- Query notes by SQL
- Export documents as Markdown
- Read/write workspace files through SiYuan file APIs
API References
- references/api-zh.md (Chinese)
- references/api.md (English)
Common Examples
List Notebooks
const SIYUAN_API_TOKEN = process.env.SIYUAN_API_TOKEN;
const SIYUAN_API_URL = process.env.SIYUAN_API_URL || 'http://127.0.0.1:6806';
fetch(`${SIYUAN_API_URL}/api/notebook/lsNotebooks`, {
method: 'POST',
headers: {
'Authorization': 'token ' + SIYUAN_API_TOKEN,
'Content-Type': 'application/json'
},
body: JSON.stringify({})
})
Create Document with Markdown
const SIYUAN_API_TOKEN = process.env.SIYUAN_API_TOKEN;
const SIYUAN_API_URL = process.env.SIYUAN_API_URL || 'http://127.0.0.1:6806';
fetch(`${SIYUAN_API_URL}/api/filetree/createDocWithMd`, {
method: 'POST',
headers: {
'Authorization': 'token ' + SIYUAN_API_TOKEN,
'Content-Type': 'application/json'
},
body: JSON.stringify({
notebook: '笔记本ID',
path: '/文档路径',
markdown: '# 文档标题\n\n正文内容...'
})
})
Append Block
const SIYUAN_API_TOKEN = process.env.SIYUAN_API_TOKEN;
const SIYUAN_API_URL = process.env.SIYUAN_API_URL || 'http://127.0.0.1:6806';
fetch(`${SIYUAN_API_URL}/api/block/appendBlock`, {
method: 'POST',
headers: {
'Authorization': 'token ' + SIYUAN_API_TOKEN,
'Content-Type': 'application/json'
},
body: JSON.stringify({
parentID: '父块ID',
dataType: 'markdown',
data: '追加的内容'
})
})
SQL Query
const SIYUAN_API_TOKEN = process.env.SIYUAN_API_TOKEN;
const SIYUAN_API_URL = process.env.SIYUAN_API_URL || 'http://127.0.0.1:6806';
fetch(`${SIYUAN_API_URL}/api/query/sql`, {
method: 'POST',
headers: {
'Authorization': 'token ' + SIYUAN_API_TOKEN,
'Content-Type': 'application/json'
},
body: JSON.stringify({
stmt: 'SELECT id, content FROM blocks WHERE content LIKE "%关键词%" LIMIT 10'
})
})
Notes
- Repeated
createDocWithMdon the same path does not overwrite existing documents. - Custom block attributes must be prefixed with
custom-. - All endpoints use
POSTand return{ code, msg, data }. - Header format is
Authorization: token <your-token>(lowercasetoken).
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。
标签
同类 Skill
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
self-improving-agent
self-improving-agent
下载 416.7k
✨
Self-Improving + Proactive Agent
Self-Improving + Proactive Agent
下载 177.1k
✨
Gog
Gog
下载 165k