一键导入
siyuan-note
思源笔记 API 集成与知识库管理。Use when "思源笔记", "SiYuan Note", "知识库管理", "笔记操作", "siyuan API". 支持笔记 CRUD、SQL 查询、批量操作、备份导出。 需要 SIYUAN_HOST 和 SIYUAN_TOKEN 环境变量。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
思源笔记 API 集成与知识库管理。Use when "思源笔记", "SiYuan Note", "知识库管理", "笔记操作", "siyuan API". 支持笔记 CRUD、SQL 查询、批量操作、备份导出。 需要 SIYUAN_HOST 和 SIYUAN_TOKEN 环境变量。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
减少常见 LLM 编码失误的行为准则。Use when "写代码", "改代码", "重构", "code", "refactor", "implement", "review code", "编写/修改本仓库代码" — 即任何在本项目里写、改、重构、审查代码之前。 四条原则:先想后写 / 极简优先 / 外科手术式改动 / 目标驱动执行。 Derived from Andrej Karpathy's observations on LLM coding pitfalls.
每日 arXiv AI 论文精选系统。自动从 arXiv 抓取最新 cs.AI/cs.LG/cs.CL/cs.CV/cs.RO 论文,用 DeepSeek 评分筛选,生成中文摘要,通过邮件和 Bark 推送。
Patent search via Google Patents (Serper.dev API). Search by keyword, inventor, assignee, or patent number. Use when checking patentability, analyzing competitors' patent portfolios, assessing infringement risks, or researching technology landscapes. Triggered by "专利检索", "patent search", "查专利", "专利布局", or any patent-related query.
小红书检索与发布工具。Use when "小红书检索", "发布小红书", "xhs MCP", "搜索小红书内容". 基于本地 MCP Server 或 xhs-mcp CLI,支持搜索、查看、发布三种操作。
This skill should be used when the user wants to generate Chinese patent application forms (专利申请表), or mentions "patents", "inventions", "专利", "申请表", or wants to protect technical innovations. It automatically searches prior art via SerpAPI before drafting.
每日科技早报。27+ RSS源并发抓取,智能分类(AI/区块链/游戏/科技/金融),质量评分过滤,可选 DeepSeek 英译中,邮件+Bark 推送。
| name | siyuan-note |
| description | 思源笔记 API 集成与知识库管理。Use when "思源笔记", "SiYuan Note", "知识库管理", "笔记操作", "siyuan API". 支持笔记 CRUD、SQL 查询、批量操作、备份导出。 需要 SIYUAN_HOST 和 SIYUAN_TOKEN 环境变量。 |
export SIYUAN_HOST="http://127.0.0.1:6806"
export SIYUAN_TOKEN="your-api-token"
export SIYUAN_HOST="http://your-siyuan.example.com:6806"
export SIYUAN_TOKEN="your-api-token"
⚠️ 安全提示:公网访问时 Token 会明文传输,建议配置 HTTPS(需反向代理配置 SSL 证书)。
API token is found in SiYuan Settings → About.
Test connection:
python3 scripts/siyuan.py test
List all notebooks:
curl -X POST ${SIYUAN_HOST}/api/notebook/lsNotebooks \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" -d '{}'
Create notebook:
curl -X POST ${SIYUAN_HOST}/api/notebook/createNotebook \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"name": "My Notebook"}'
Delete notebook by ID:
curl -X POST ${SIYUAN_HOST}/api/notebook/removeNotebook \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id"}'
List documents in notebook:
curl -X POST ${SIYUAN_HOST}/api/filetree/listDocsByPath \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id", "path": "/"}'
Create document with Markdown:
curl -X POST ${SIYUAN_HOST}/api/filetree/createDocWithMd \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id", "path": "/my-note", "markdown": "# Title\nContent"}'
Delete document by ID:
curl -X POST ${SIYUAN_HOST}/api/filetree/removeDocByID \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"id": "doc-id"}'
Export document as Markdown:
curl -X POST ${SIYUAN_HOST}/api/export/exportMdContent \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"id": "doc-id"}'
Search content with SQL query:
curl -X POST ${SIYUAN_HOST}/api/query/sql \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"stmt": "SELECT * FROM blocks WHERE content LIKE '\''%keyword%'\'' LIMIT 10"}'
Get block content:
curl -X POST ${SIYUAN_HOST}/api/block/getBlockKramdown \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"id": "block-id"}'
Append block to document:
curl -X POST ${SIYUAN_HOST}/api/block/appendBlock \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"dataType": "markdown", "data": "New content", "parentID": "doc-id"}'
The bundled Python script provides common operations:
# Test connection
python3 scripts/siyuan.py test
# List notebooks
python3 scripts/siyuan.py ls-notebooks
# Create notebook
python3 scripts/siyuan.py create-notebook "My Notebook"
# Delete notebook
python3 scripts/siyuan.py delete-notebook "notebook-id"
# List documents in notebook
python3 scripts/siyuan.py ls-docs "notebook-id"
# Create document
python3 scripts/siyuan.py create-doc "notebook-id" "/my-path" "# Title\nContent"
# Delete document
python3 scripts/siyuan.py delete-doc "doc-id"
# Search
python3 scripts/siyuan.py search "keyword"
# Export markdown
python3 scripts/siyuan.py export-md "doc-id" /path/to/save.md
# Export all documents to directory
python3 scripts/siyuan.py export-all-notebooks "/backup/path"
# Get statistics
python3 scripts/siyuan.py stats
# Find duplicate documents
python3 scripts/siyuan.py find-duplicates
# Find documents by name pattern
python3 scripts/siyuan.py find "pattern"
# Export documents from a specific notebook
python3 scripts/siyuan.py export-notebook "notebook-id" "/output/path"
# 1. List notebooks to get ID
python3 scripts/siyuan.py ls-notebooks
# 2. Create document in notebook
python3 scripts/siyuan.py create-doc "notebook-id" "/my-new-note" "# My New Note\n\nContent here"
# 1. Search for content
python3 scripts/siyuan.py search "keyword"
# 2. Get document ID from results and export
python3 scripts/siyuan.py export-md "doc-id" "/output/note.md"
# Export all notebooks to backup directory
python3 scripts/siyuan.py export-all-notebooks "~/Desktop/siyuan_backup_$(date +%Y%m%d)"
# 1. List documents in notebook
python3 scripts/siyuan.py ls-docs "notebook-id"
# 2. Find documents by pattern
python3 scripts/siyuan.py find "test" --notebook "notebook-id"
# 3. Delete unwanted documents in batch
echo "id1\nid2\nid3" | xargs -I {} python3 scripts/siyuan.py delete-doc {}
# Create new notebook
python3 scripts/siyuan.py create-notebook "Project Docs"
# Get notebook ID (or use directly)
NOTEBOOK_ID="new-notebook-id"
# Create folder structure
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation" "# Documentation"
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation/Getting Started" "# Getting Started"
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation/API Reference" "# API Reference"
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation/Examples" "# Examples"
# Get notebook statistics
python3 scripts/siyuan.py stats
# Find potential duplicates
python3 scripts/siyuan.py find-duplicates
# Export all notes for analysis
python3 scripts/siyuan.py export-all-notebooks "backup_dir"
# Then import organized notes as needed
All endpoints return:
{
"code": 0,
"msg": "",
"data": {...}
}
Check code === 0 for success. msg contains error details on failure.
Common error codes:
-1: Parameter/execution error401: Unauthorized (invalid token)403: Permission denied404: Resource not found503: Service unavailable (SiYuan not running)Check msg field for details.
# Create document in subfolder
python3 scripts/siyuan.py create-doc "notebook-id" "/category/subcategory/doc-name" "# Title"
# List documents in subfolder
python3 scripts/siyuan.py ls-docs "notebook-id" "/category"
Export all documents preserving folder structure:
python3 scripts/siyuan.py export-all-notebooks "/backup" --hierarchy
# Find documents by title
curl -X POST ${SIYUAN_HOST}/api/query/sql \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"stmt": "SELECT * FROM blocks WHERE type = \"d\" AND content LIKE \"My Title%\""}'
# Get document tree
curl -X POST ${SIYUAN_HOST}/api/filetree/getDocTree \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id"}'
See references/api_reference.md for complete API documentation including:
| Variable | Description | Default |
|---|---|---|
SIYUAN_HOST | SiYuan Note server URL | http://127.0.0.1:6806 (本地) 或 http://your-siyuan.example.com:6806 (公网) |
SIYUAN_TOKEN | API authentication token | (required) |
如果你在外网需要访问运行在家中或服务器上的 SiYuan Note:
# 公网域名访问
export SIYUAN_HOST="http://your-siyuan.example.com:6806"
export SIYUAN_TOKEN="你的Token"
server {
listen 443 ssl;
server_name your-siyuan.example.com;
ssl_certificate /path/to/ssl/cert.pem;
ssl_certificate_key /path/to/ssl/key.pem;
location / {
proxy_pass http://127.0.0.1:6806;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
配置 HTTPS 后使用:
export SIYUAN_HOST="https://your-siyuan.example.com"
ls-docs to list available documentstest command