fabric-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFabric API (HTTP via Node/Python)
Fabric API(基于Node/Python的HTTP实现)
Use this skill when you need to read or write content in a user's Fabric workspace using the Fabric HTTP API ().
https://api.fabric.soThis version avoids bash-only wrapper scripts. It ships cross-platform helpers:
- Node: (recommended)
{baseDir}/scripts/fabric.mjs - Python:
{baseDir}/scripts/fabric.py
当你需要通过Fabric HTTP API()读取或写入用户Fabric工作区中的内容时,可以使用此技能。
https://api.fabric.so本版本摒弃了仅支持bash的包装脚本,提供跨平台辅助工具:
- Node:(推荐)
{baseDir}/scripts/fabric.mjs - Python:
{baseDir}/scripts/fabric.py
Critical gotchas (read first)
关键注意事项(请先阅读)
- There is no endpoint in the bundled OpenAPI spec. To create a “note”, use
POST /v2/notes.POST /v2/notepads - Most create endpoints require :
parentId- A folder UUID or one of: ,
@alias::inbox@alias::bin
- A folder UUID or one of:
- Notepad creation requires:
parentId- and either (markdown string) or
text(advanced/structured)ydoc
- must be an array of objects, each item either:
tags- or
{ "name": "tag name" }{ "id": "<uuid>" } - Never strings, never nested arrays.
- Field name gotcha: the API schema uses (not
name). If the user says “title”, map it totitlein requests.name
When the user doesn’t specify a destination folder, default to:
parentId: "@alias::inbox"
- 捆绑的OpenAPI规范中没有端点。要创建“笔记”,请使用**
POST /v2/notes**。POST /v2/notepads - 大多数创建端点需要****:
parentId- 文件夹UUID 或以下别名之一:、
@alias::inbox@alias::bin
- 文件夹UUID 或以下别名之一:
- 创建记事本需要:
parentId- 以及**(Markdown字符串)或
text(高级/结构化格式)二者之一**ydoc
- 必须是对象数组,每个元素需为:
tags- 或
{ "name": "tag name" }{ "id": "<uuid>" } - 不能是字符串,也不能是嵌套数组。
- 字段名称注意事项:API架构使用(而非
name)。如果用户提到“标题”,请在请求中映射为title字段。name
当用户未指定目标文件夹时,默认使用:
parentId: "@alias::inbox"
Setup (OpenClaw / Clawdbot)
设置(OpenClaw / Clawdbot)
This skill expects the Fabric API key in:
FABRIC_API_KEY
OpenClaw config example ():
~/.openclaw/openclaw.jsonjson5
{
skills: {
entries: {
"fabric-api": {
enabled: true,
apiKey: "YOUR_FABRIC_API_KEY"
}
}
}
}Notes:
- is a convenience for skills that declare
apiKey; it injectsprimaryEnvfor the duration of an agent run.FABRIC_API_KEY - Don’t paste the API key into prompts, client-side code, or logs.
此技能需要将Fabric API密钥存储在:
FABRIC_API_KEY
OpenClaw配置示例():
~/.openclaw/openclaw.jsonjson5
{
skills: {
entries: {
"fabric-api": {
enabled: true,
apiKey: "YOUR_FABRIC_API_KEY"
}
}
}
}注意:
- 是为声明了
apiKey的技能提供的便捷配置;它会在Agent运行期间注入primaryEnv环境变量。FABRIC_API_KEY - 请勿将API密钥粘贴到提示词、客户端代码或日志中。
HTTP basics
HTTP基础
- Base URL: (override with
https://api.fabric.soif needed)FABRIC_BASE - Auth header:
X-Api-Key: $FABRIC_API_KEY - JSON header (for JSON bodies):
Content-Type: application/json
- 基础URL:(如有需要,可通过
https://api.fabric.so覆盖)FABRIC_BASE - 认证头:
X-Api-Key: $FABRIC_API_KEY - JSON头(用于JSON请求体):
Content-Type: application/json
Convenience scripts (cross-platform)
便捷脚本(跨平台)
Node helper (recommended)
Node辅助工具(推荐)
bash
node {baseDir}/scripts/fabric.mjs GET /v2/user/me
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"name":"Test note","text":"Hello","parentId":"@alias::inbox"}'bash
node {baseDir}/scripts/fabric.mjs GET /v2/user/me
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"name":"Test note","text":"Hello","parentId":"@alias::inbox"}'Python helper
Python辅助工具
bash
python3 {baseDir}/scripts/fabric.py GET /v2/user/me
python3 {baseDir}/scripts/fabric.py POST /v2/notepads --json '{"name":"Test note","text":"Hello","parentId":"@alias::inbox"}'Notes:
- Both helpers print the response body on success.
- On HTTP errors (4xx/5xx), they print to stderr and still print the response body, then exit non‑zero (similar to
HTTP <code> <reason>).curl --fail-with-body - If you pass an absolute URL (), the helpers do not attach
https://...unless you explicitly passX-Api-Key.--with-key
bash
python3 {baseDir}/scripts/fabric.py GET /v2/user/me
python3 {baseDir}/scripts/fabric.py POST /v2/notepads --json '{"name":"Test note","text":"Hello","parentId":"@alias::inbox"}'注意:
- 两个辅助工具在成功时都会打印响应体。
- 遇到HTTP错误(4xx/5xx)时,它们会向stderr打印,同时仍会打印响应体,然后以非零状态码退出(类似
HTTP <code> <reason>的行为)。curl --fail-with-body - 如果传入绝对URL(),除非显式传递
https://...参数,否则辅助工具不会附加--with-key头。X-Api-Key
Core workflows
核心工作流
1) Create a notepad (note)
1) 创建记事本(笔记)
Endpoint:
POST /v2/notepadsRules:
- Map user “title” →
name - Use for markdown content
text - Always include
parentId - If you’re debugging 400s, start minimal (required fields only), then add , then
name.tags
Minimal create:
bash
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"parentId":"@alias::inbox","text":"Hello"}'Create with a name:
bash
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"name":"Calendar Test Note","text":"Created via OpenClaw","parentId":"@alias::inbox"}'Create with tags (correct shape):
bash
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"name":"Ideas","text":"# Ideas\\n\\n- First\\n- Second\\n","parentId":"@alias::inbox","tags":[{"name":"ideas"},{"name":"draft"}]}'If you keep seeing tag validation errors, temporarily omit and create the notepad first.
tags端点:
POST /v2/notepads规则:
- 将用户所说的“title”映射为字段
name - 使用字段存储Markdown内容
text - 始终包含
parentId - 如果调试400错误,请从最小配置开始(仅必填字段),然后添加,再添加
name。tags
最简创建命令:
bash
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"parentId":"@alias::inbox","text":"Hello"}'带名称的创建命令:
bash
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"name":"Calendar Test Note","text":"Created via OpenClaw","parentId":"@alias::inbox"}'带标签的创建命令(正确格式):
bash
node {baseDir}/scripts/fabric.mjs POST /v2/notepads --json '{"name":"Ideas","text":"# Ideas\\n\\n- First\\n- Second\\n","parentId":"@alias::inbox","tags":[{"name":"ideas"},{"name":"draft"}]}'如果持续遇到标签验证错误,请暂时省略字段,先创建记事本。
tags2) Create a folder
2) 创建文件夹
Endpoint:
POST /v2/foldersbash
node {baseDir}/scripts/fabric.mjs POST /v2/folders --json '{"name":"My new folder","parentId":"@alias::inbox","description":null}'端点:
POST /v2/foldersbash
node {baseDir}/scripts/fabric.mjs POST /v2/folders --json '{"name":"My new folder","parentId":"@alias::inbox","description":null}'3) Create a bookmark
3) 创建书签
Endpoint:
POST /v2/bookmarksbash
node {baseDir}/scripts/fabric.mjs POST /v2/bookmarks --json '{"url":"https://example.com","parentId":"@alias::inbox","name":"Example","tags":[{"name":"reading"}]}'端点:
POST /v2/bookmarksbash
node {baseDir}/scripts/fabric.mjs POST /v2/bookmarks --json '{"url":"https://example.com","parentId":"@alias::inbox","name":"Example","tags":[{"name":"reading"}]}'4) Browse resources (list children of a folder)
4) 浏览资源(列出文件夹子项)
Endpoint:
POST /v2/resources/filterImportant:
- This endpoint’s expects a UUID (not an alias).
parentId - If you only have an alias, resolve it by listing resource roots and picking the inbox/bin folder ID.
bash
node {baseDir}/scripts/fabric.mjs POST /v2/resources/filter --json '{"parentId":"PARENT_UUID_HERE","limit":50,"order":{"property":"modifiedAt","direction":"DESC"}}'端点:
POST /v2/resources/filter重要提示:
- 此端点的需要UUID(而非别名)。
parentId - 如果只有别名,请通过列出资源根目录并选择收件箱/垃圾箱的文件夹ID来解析。
bash
node {baseDir}/scripts/fabric.mjs POST /v2/resources/filter --json '{"parentId":"PARENT_UUID_HERE","limit":50,"order":{"property":"modifiedAt","direction":"DESC"}}'5) Search
5) 搜索
Endpoint:
POST /v2/searchUse search when the user gives a fuzzy description (“the note about…”).
bash
node {baseDir}/scripts/fabric.mjs POST /v2/search --json '{"queries":[{"mode":"text","text":"meeting notes","filters":{"kinds":["notepad"]}}],"pagination":{"page":1,"pageSize":20},"sort":{"field":"modifiedAt","order":"desc"}}'端点:
POST /v2/search当用户给出模糊描述(如“关于……的笔记”)时,使用搜索功能。
bash
node {baseDir}/scripts/fabric.mjs POST /v2/search --json '{"queries":[{"mode":"text","text":"meeting notes","filters":{"kinds":["notepad"]}}],"pagination":{"page":1,"pageSize":20},"sort":{"field":"modifiedAt","order":"desc"}}'Error handling + retries (practical guidance)
错误处理与重试(实用指南)
- 400 Bad Request: schema validation. Re-check required fields, and that is
tagsnot nested.[{name}|{id}] - 401/403: auth/subscription/permission. Stop and report the error details; don’t brute-force.
- 404: wrong endpoint, wrong ID, or no access.
- 429: rate limiting. Back off (sleep + jitter) and retry reads. Avoid blind retries on create (you may create duplicates).
- 5xx: transient; retry with backoff.
- 400 Bad Request:架构验证错误。重新检查必填字段,确保是
tags格式而非嵌套结构。[{name}|{id}] - 401/403:认证/订阅/权限问题。停止操作并报告错误详情;不要暴力重试。
- 404:端点错误、ID错误或无访问权限。
- 429:速率限制。退避(休眠+随机延迟)并重试读取操作。避免对创建操作盲目重试(可能会创建重复项)。
- 5xx:临时错误;退避后重试。
Reference files
参考文件
- OpenAPI spec (source of truth):
{baseDir}/fabric-api.yaml - Extra schema notes:
{baseDir}/references/REFERENCE.md - Debug playbook:
{baseDir}/references/TROUBLESHOOTING.md
- OpenAPI规范(权威来源):
{baseDir}/fabric-api.yaml - 额外架构说明:
{baseDir}/references/REFERENCE.md - 调试手册:
{baseDir}/references/TROUBLESHOOTING.md