Xpersona
S

Siyuan Note

CLAWHUB · Unverified

思源笔记(SiYuan Note)本地 API 操作助手。用于读写笔记本、文档、块、搜索、模板、SQL 查询等本地笔记操作。触发场景:用户提到"思源笔记"、"SiYuan"、"帮我创建文档"、"搜索笔记"、"查询数据库"等。 Skill: Siyuan Note Owner: moxunjinmu Summary: 思源笔记(SiYuan Note)本地 API 操作助手。用于读写笔记本、文档、块、搜索、模板、SQL 查询等本地笔记操作。触发场景:用户提到"思源笔记"、"SiYuan"、"帮我创建文档"、"搜索笔记"、"查询数据库"等。 Tags: latest:1.0.0 Version history: v1.0.0 | 2026-03-26T15:00:23.164Z | auto SiYuan Note API Skill 1.0.0 — initial release: - Provides local API helper for SiYuan Note, enabling notebook/document/block CRUD, search, templates, and SQL queries. - Supports common

62
Rank
84
Safety
976
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 976 downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17dx1mj03ser47dtz99shr9t983mp6t:siyuan-note
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-moxunjinmu-siyuan-note/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

11,747 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

---
name: siyuan-note
description: 思源笔记(SiYuan Note)本地 API 操作助手。用于读写笔记本、文档、块、搜索、模板、SQL 查询等本地笔记操作。触发场景:用户提到"思源笔记"、"SiYuan"、"帮我创建文档"、"搜索笔记"、"查询数据库"等。
---

# 思源笔记(SiYuan Note)API Skill

## 基础规范

- **API 基础 URL**:`http://127.0.0.1:6806`
- **认证**:请求头 `Authorization: Token <你的API Token>`(在 思源笔记 → 设置 → 关于 中查看)
- **方法**:全部 POST,Content-Type: `application/json`
- **返回格式**:`{ "code": 0, "msg": "", "data": ... }`,`code` 非 0 表示异常

> **注意**:代码执行必须包含 Token,调用示例会标注需要 Token 的端点。

## 常用操作速查

### 列出所有笔记本
```bash
curl -X POST http://127.0.0.1:6806/api/notebook/lsNotebooks \
  -H "Authorization: Token <TOKEN>"
```

### 创建文档(通过 Markdown)
```bash
curl -X POST http://127.0.0.1:6806/api/filetree/createDocWithMd \
  -H "Authorization: Token <TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"notebook": "<笔记本ID>", "path": "/我的文档", "markdown": "# 标题\n\n内容"}'
```

### 执行 SQL 查询
```bash
curl -X POST http://127.0.0.1:6806/api/query/sql \
  -H "Authorization: Token <TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"stmt": "SELECT * FROM blocks WHERE content LIKE '\''%关键词%'\'' LIMIT 10"}'
```

### 插入块到文档
```bash
curl -X POST http://127.0.0.1:6806/api/block/appendBlock \
  -H "Authorization: Token <TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"data": "新段落内容", "dataType": "markdown", "parentID": "<父块ID>"}'
```

### 搜索文档
```bash
curl -X POST http://127.0.0.1:6806/api/query/sql \
  -H "Authorization: Token <TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"stmt": "SELECT id, hpath, title FROM blocks WHERE type = '\''d'\'' AND title LIKE '\''%搜索词%'\'' LIMIT 20"}'
```

## 核心工作流程

### 工作流程 1:创建新文档
1. 调用 `lsNotebooks` 列出笔记本 → 拿到 `notebook ID`
2. 调用 `createDocWithMd` 创建文档 → 拿到 `文档ID`
3. (可选)调用 `setBlockAttrs` 设置文档属性

### 工作流程 2:搜索并读取笔记
1. 调用 `getNotebookConf` 确认笔记本存在
2. 调用 SQL `SELECT * FROM blocks WHERE content LIKE '%关键词%' LIMIT N` 全文搜索
3. 对文档 ID 调用 `getBlockKramdown` 或 `exportMdContent` 获取内容

### 工作流程 3:向文档追加内容
1. 获取目标文档的根块 ID(通常等于文档 ID 本身)
2. 调用 `appendBlock` 在文档末尾追加新块
3. 或调用 `prependBlock` 在文档开头插入

### 工作流程 4:使用模板
1. 调用 `renderSprig` 渲染 Sprig 模板表达式(如 `{{now | date "2006-01-02"}}`)
2. 结合 `createDocWithMd` 创建带有日期标题的文档

## SQL 查询要点

关键表:
- `blocks` — 所有块(段落、标题、代码块等)
  - `id` / `hpath` / `title` / `content` / `type` / `subtype` / `markdown` / `created` / `updated`
- `blocks` 表中 `type = 'd'` 为文档,标题块 `type = 'h'`,段落 `type = 'p'`

常用查询:
```sql
-- 搜索包含关键词的块
SELECT id, hpath, content FROM blocks 
WHERE content LIKE '%关键词%' LIMIT 20;

-- 列出某笔记本下所有文档
SELECT id, title, hpath FROM blocks 
WHERE notebook = '<笔记本ID>' AND type = 'd';

-- 搜索文档标题
SELECT id, hpath, title FROM blocks 
WHERE type = 'd' AND title LIKE '%标题%' LIMIT 10;
```

## 重要限制

- SQL 接口在发布模式(Publication)下需要开启文档读写权限,否则会被禁止
- 资源文件上传使用 `multipart/form-data`,不是 JSON
- API 全部为本地调用,思源笔记必须运行在本地

## 完整 API 参考

见 [references/api.md](references/api.md)(包含所有端点的完整说明)

_meta.json

{
  "ownerId": "kn7fndrnpsmws8dvrwspj82p7s8270ga",
  "slug": "siyuan-note",
  "version": "1.0.0",
  "publishedAt": 1774537223164
}

references/api.md

# 思源笔记 API 参考

> 来源:[官方 API 文档](https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md)

## 规范

- **Base URL**:`http://127.0.0.1:6806`
- **全部 POST**,Content-Type: `application/json`
- **认证**:`Authorization: Token <token>`(设置 → 关于 查看)
- **响应**:`{ "code": 0, "msg": "", "data": ... }`,code 非 0 = 异常

---

## 笔记本 `/api/notebook/`

### 列出笔记本
```
POST /api/notebook/lsNotebooks
无参数
```

### 打开笔记本
```json
{ "notebook": "<笔记本ID>" }
```

### 关闭笔记本
```json
{ "notebook": "<笔记本ID>" }
```

### 创建笔记本
```json
{ "name": "笔记本名称" }
```

### 重命名笔记本
```json
{ "notebook": "<笔记本ID>", "name": "新名称" }
```

### 删除笔记本
```json
{ "notebook": "<笔记本ID>" }
```

### 获取笔记本配置
```json
{ "notebook": "<笔记本ID>" }
```

### 保存笔记本配置
```json
{
  "notebook": "<笔记本ID>",
  "conf": { "name": "...", "closed": false, "refCreateSavePath": "", "createDocNameTemplate": "", "dailyNoteSavePath": "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}", "dailyNoteTemplatePath": "" }
}
```

---

## 文档 `/api/filetree/`

### 通过 Markdown 创建文档
```json
{
  "notebook": "<笔记本ID>",
  "path": "/foo/bar",
  "markdown": "# 标题\n\n内容"
}
```
- `path` 需要以 `/` 开头
- 重复调用不会覆盖已有文档

### 重命名文档(按路径)
```json
{ "notebook": "<笔记本ID>", "path": "/xxx.sy", "title": "新标题" }
```

### 重命名文档(按 ID)
```json
{ "id": "<文档ID>", "title": "新标题" }
```

### 删除文档(按路径)
```json
{ "notebook": "<笔记本ID>", "path": "/xxx.sy" }
```

### 删除文档(按 ID)
```json
{ "id": "<文档ID>" }
```

### 移动文档(按路径)
```json
{ "fromPaths": ["/xxx.sy"], "toNotebook": "<目标笔记本ID>", "toPath": "/" }
```

### 移动文档(按 ID)
```json
{ "fromIDs": ["<文档ID>"], "toID": "<目标父文档或笔记本ID>" }
```

### 根据路径获取人类可读路径
```json
{ "notebook": "<笔记本ID>", "path": "/xxx/xxx.sy" }
```

### 根据 ID 获取人类可读路径
```json
{ "id": "<块ID>" }
```

### 根据 ID 获取存储路径
```json
{ "id": "<块ID>" }
```

### 根据人类可读路径获取 IDs
```json
{ "path": "/foo/bar", "notebook": "<笔记本ID>" }
```

---

## 资源文件 `/api/asset/`

### 上传资源文件
```
POST /api/asset/upload
Content-Type: multipart/form-data
```
- `assetsDirPath`:资源目录,如 `"/assets/"` 或 `"/assets/sub/"`
- `file[]`:文件列表

---

## 块 `/api/block/`

### 插入块
```json
{
  "dataType": "markdown",
  "data": "内容",
  "nextID": "<后一个块ID>",
  "previousID": "<前一个块ID>",
  "parentID": "<父块ID>"
}
```
- `nextID` / `previousID` / `parentID` 至少有一个必须有值,优先级:nextID > previousID > parentID

### 插入前置子块
```json
{ "data": "内容", "dataType": "markdown", "parentID": "<父块ID>" }
```

### 插入后置子块
```json
{ "data": "内容", "dataType": "markdown", "parentID": "<父块ID>" }
```

### 更新块
```json
{ "dataType": "markdown", "data": "新内容", "id": "<块ID>" }
```

### 删除块
```json
{ "id": "<块ID>" }
```

### 移动块
```json
{ "id": "<块ID>", "previousID": "<前一个块ID>", "parentID": "<父块ID>" }
```

### 折叠块
```json
{ "id": "<块ID>" }
```

### 展开块
```json
{ "id": "<块ID>" }
```

### 获取块 kramdown 源码
```json
{ "id": "<块ID>" }
```

### 获取子块
```json
{ "id": "<父块ID>" }
```

### 转移块引用
```json
{ "fromID": "<源块ID>", "toID": "<目标块ID>", "refIDs": ["<引用块ID>"] }
```

---

## 属性 `/api/attr/`

### 设置块属性
```json
{ "id": "<块ID>", "attrs": { "custom-attr1

skill-card.md

## Description:

SiYuan Note local API helper for reading and writing notebooks, documents, blocks, searches, templates, and SQL queries in a local SiYuan workspace.

This skill is ready for commercial/non-commercial use.

## Publisher:

[moxunjinmu](https://clawhub.ai/user/moxunjinmu)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and SiYuan users use this skill to let an agent operate a local SiYuan Note instance, including creating documents, searching notes, appending or updating blocks, exporting Markdown, rendering templates, and running SQL queries.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The skill can give an agent broad authenticated access to private local SiYuan notes.

Mitigation: Install only when the agent is trusted with the SiYuan API token and private note contents.

Risk: Write, delete, export, and SQL operations can modify or expose note data.

Mitigation: Confirm each destructive, export, or SQL action before execution and avoid broad or ambiguous prompts.

Risk: Documented proxy behavior may send note contents outside the local SiYuan instance if used intentionally.

Mitigation: Do not send note contents through proxy endpoints unless external network access is explicitly intended.

Risk: The helper script depends on Python requests and uses an API token from the local environment.

Mitigation: Run the helper in an isolated Python environment with reviewed dependencies and scoped environment variables.

## Reference(s):

- [SiYuan API reference](references/api.md)
- [Official SiYuan API documentation](https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md)
- [ClawHub skill page](https://clawhub.ai/moxunjinmu/skills/siyuan-note)

## Skill Output:

**Output Type(s):** [guidance, shell commands, code, configuration, markdown]

**Output Format:** [Markdown with inline shell commands, Python helper usage, JSON request examples, SQL snippets, and generated note content]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [May require a local SiYuan instance and SIYUAN_TOKEN for authenticated operations.]

## Skill Version(s):

1.0.0 (source: release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Siyuan Note and adjacent AI workflows.