知识库 API
鉴权:所有接口均需 Bearer Token
TOKEN=$(cat ~/.octohz_token | tr -d '\n')
待办事项 /api/my/todos
# 列表(置顶 > 未完成 > 已完成)
curl "https://octohz.com/api/my/todos" -H "Authorization: Bearer $TOKEN"
# 新建
curl -X POST "https://octohz.com/api/my/todos" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"content": "待办内容"}'
# 标记完成
curl -X PATCH "https://octohz.com/api/my/todos/1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"isDone": true}'
# 置顶
curl -X PATCH "https://octohz.com/api/my/todos/1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"isPinned": true}'
# 修改内容
curl -X PATCH "https://octohz.com/api/my/todos/1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"content": "新内容"}'
# 删除
curl -X DELETE "https://octohz.com/api/my/todos/1" -H "Authorization: Bearer $TOKEN"
PATCH 为局部更新,只传要改的字段,可更新: content、isDone、isPinned
私人文档 /api/my/docs
# 列表
curl "https://octohz.com/api/my/docs" -H "Authorization: Bearer $TOKEN"
# 新建
curl -X POST "https://octohz.com/api/my/docs" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "文档标题", "content": "支持 GFM Markdown"}'
# 更新(PUT 整体替换,需传入所有要保留的字段)
curl -X PUT "https://octohz.com/api/my/docs/1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "新标题", "content": "新内容"}'
# 删除
curl -X DELETE "https://octohz.com/api/my/docs/1" -H "Authorization: Bearer $TOKEN"
POST/PUT 字段
| 字段 | 必填 | 说明 |
|---|---|---|
| title | ✓ | 文档标题 |
| content | ✓ | GFM Markdown |
| categoryId | 分类 ID(null 清除;PUT 不传则清空) | |
| isPinned | 置顶 | |
| isPublic | 公开分享 |
公开链接:https://octohz.com/my/docs?doc=123
文档分类
# 获取分类
curl "https://octohz.com/api/my/doc-categories" -H "Authorization: Bearer $TOKEN"
# 新建
curl -X POST "https://octohz.com/api/my/doc-categories" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "分类名", "parentId": null}'
# 删除(文档移至未分类)
curl -X DELETE "https://octohz.com/api/my/doc-categories/1" -H "Authorization: Bearer $TOKEN"
# 重命名
curl -X PATCH "https://octohz.com/api/my/doc-categories/1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "新名称"}'
导航收藏 /api/my/navs
# 列表
curl "https://octohz.com/api/my/navs" -H "Authorization: Bearer $TOKEN"
# 新建
curl -X POST "https://octohz.com/api/my/navs" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "GitHub", "url": "https://github.com", "description": "代码托管", "categoryId": 1}'
# 更新(PATCH 局部更新,只传要改的字段)
curl -X PATCH "https://octohz.com/api/my/navs/1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"description": "新描述"}'
# 删除
curl -X DELETE "https://octohz.com/api/my/navs/1" -H "Authorization: Bearer $TOKEN"
POST 必填: title、url
导航分类
curl "https://octohz.com/api/my/nav-categories" -H "Authorization: Bearer $TOKEN"
curl -X POST "https://octohz.com/api/my/nav-categories" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "分类名"}'
# 重命名
curl -X PATCH "https://octohz.com/api/my/nav-categories/1" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "新名称"}'
# 删除(导航移至未分类)
curl -X DELETE "https://octohz.com/api/my/nav-categories/1" -H "Authorization: Bearer $TOKEN"