Skill metadata
Reference: full SKILL.md
The following is the complete skill definition that Mibyan loads when this skill is triggered. This is what the agent sees as instructions when the skill is active.
SiYuan Note API
Use the SiYuan kernel API via curl to search, read, create, update, and delete blocks and documents in a self-hosted knowledge base. No extra tools needed — just curl and an API token.Prerequisites
- Install and run SiYuan (desktop or Docker)
- Get your API token: Settings > About > API token
- Store it in
${mibyan_HOME:-~/.mibyan}/.env:SIYUAN_URLdefaults tohttp://127.0.0.1:6806if not set.
API Basics
All SiYuan API calls are POST with JSON body. Every request follows this pattern:code: 0 means success. Any other value is an error — check msg for details.
ID format: SiYuan IDs look like 20210808180117-6v0mkxr (14-digit timestamp + 7 alphanumeric chars).
Quick Reference
Common Operations
Search (Full-Text)
Search (SQL)
Query the blocks database directly. Only SELECT statements are safe.id, parent_id, root_id, box (notebook ID), path, content, type, subtype, created, updated.
Read Block Content
Returns block content in Kramdown (Markdown-like) format.Read Child Blocks
Get Human-Readable Path
Get Block Attributes
List Notebooks
List Documents in a Notebook
Create a Document
Create a Notebook
Append Block to Document
/api/block/prependBlock (same params, inserts at the beginning) and /api/block/insertBlock (uses previousID instead of parentID to insert after a specific block).
Update Block Content
Rename a Document
Set Block Attributes
Custom attributes must be prefixed withcustom-:
Delete a Block
/api/filetree/removeDocByID with {"id": "DOC_ID"}.
To delete a notebook: use /api/notebook/removeNotebook with {"notebook": "NOTEBOOK_ID"}.
Export Document as Markdown
Block Types
Commontype values in SQL queries:
Pitfalls
- All endpoints are POST — even read-only operations. Do not use GET.
- SQL safety: only use SELECT queries. INSERT/UPDATE/DELETE/DROP are dangerous and should never be sent.
- ID validation: IDs match the pattern
YYYYMMDDHHmmss-xxxxxxx. Reject anything else. - Error responses: always check
code != 0in responses before processingdata. - Large documents: block content and export results can be very large. Use
LIMITin SQL and pipe throughjqto extract only what you need. - Notebook IDs: when working with a specific notebook, get its ID first via
lsNotebooks.

