text
https://openapi.biji.com
所有 API 请求必须使用此 Base URL,不要使用 biji.com 或其他地址。
⚠️ Agent 必读:每次调用 API 前,先检查
$GETNOTE_API_KEY是否存在。若不存在, 自动发起 OAuth 授权流程(无需用户主动说"配置"),告知用户需要先授权才能使用。
当检测到未配置时,Agent 会自动:
用户只需点击链接、授权,即可无缝使用。
~/.openclaw/openclaw.json 中添加:json
{
"skills": {
"entries": {
"getnote": {
"apiKey": "gk_live_你的key",
"env": {
"GETNOTE_CLIENT_ID": "cli_你的id",
"GETNOTE_OWNER_ID": "ou_你的飞书ID(可选,用于权限控制)"
}
}
}
}
}
笔记 ID( id、 note_id、 next_cursor 等)是 64 位整数(int64),超出 JavaScript Number.MAX_SAFE_INTEGER(2^53-1)范围,直接用 JSON.parse 会 静默丢失精度,导致 ID 错误,后续操作(加入知识库、删除等)会报「笔记不存在」。
正确做法:
始终把 ID 当字符串处理,不要做数值运算
代码中使用 JSON.parse 时, 先把响应文本中的 ID 数字替换为字符串:
javascript
// 替换顶层数字型 ID 字段为字符串(在 JSON.parse 之前)
const safe = text.replace(/"(id|note_id|next_cursor|parent_id|follow_id|live_id)"\s*:\s*(\d+)/g, '"$1":"$2"');
const data = JSON.parse(safe);
Python / Go 等语言原生支持大整数,无此问题
发请求时: note_id 字段传字符串或数字均可,服务端兼容两种格式
验证方法:取到 ID 后,检查 String(id).length >= 16,若满足说明是 int64,必须用字符串保存。
GETNOTE_OWNER_ID,检查 sender_id 是否匹配;不匹配时回复「抱歉,笔记是私密的,我无法操作」;未配置则不检查error.reason: "not_member" 或错误码 10201 时,引导开通会员: https://www.biji.com/checkout?product_alias=6AydVpYeKl请求头:
Authorization: $GETNOTE_API_KEY(格式: gk_live_xxx)X-Client-ID: $GETNOTE_CLIENT_ID(格式: cli_xxx)常用权限: note.content.read(读取)、 note.content.write(写入)、 note.recall.read(搜索)。
完整权限列表见 references/api-details.md。
Base URL: https://openapi.biji.com
用户意图接口关键点「配置 Get笔记」「连接笔记」OAuth Device Flow见「OAuth Device Flow」章节「记一下」「保存笔记」POST /open/api/v1/resource/note/save同步返回「改笔记」「更新笔记」POST /open/api/v1/resource/note/updatenote_id 必填,内容部分更新「保存这个链接」POST /open/api/v1/resource/note/savenote_type:"link" → 必须轮询「保存这张图」见「图片笔记流程」4 步流程,必须轮询「查我的笔记」GET /open/api/v1/resource/note/listsince_id=0 起始「看原文/转写内容」GET /open/api/v1/resource/note/detailaudio.original / web_page.content「加标签」POST /open/api/v1/resource/note/tags/add「删标签」POST /open/api/v1/resource/note/tags/deletesystem 类型不可删「删笔记」POST /open/api/v1/resource/note/delete移入回收站「查知识库」GET /open/api/v1/resource/knowledge/list含统计数据(笔记数、文件数、博主数、直播数)「建知识库」POST /open/api/v1/resource/knowledge/create每天限 50 个「笔记加入知识库」POST /open/api/v1/resource/knowledge/note/batch-add每批最多 20 条「从知识库移除」POST /open/api/v1/resource/knowledge/note/remove「查任务进度」POST /open/api/v1/resource/note/task/progress链接/图片笔记轮询用「订阅了哪些博主」GET /open/api/v1/resource/knowledge/bloggers按 topic_id 查「博主发了什么内容」GET /open/api/v1/resource/knowledge/blogger/contents需要 follow_id,列表只含摘要「博主内容原文/详情」GET /open/api/v1/resource/knowledge/blogger/content/detail需要 post_id,含原文「有哪些已完成直播」GET /open/api/v1/resource/knowledge/lives按 topic_id 查「直播总结/直播原文」GET /open/api/v1/resource/knowledge/live/detail需要 live_id「搜一下」「找找笔记里提到 XX 的」POST /open/api/v1/resource/recall全局语义召回,见「笔记召回」章节「在 XX 知识库搜 XX」POST /open/api/v1/resource/recall/knowledge知识库语义召回,见「知识库召回」章节
text
GET /open/api/v1/resource/note/list?since_id=0
参数:
返回:notes[], has_more, next_cursor, total(每次固定 20 条)
⚠️ 响应 JSON 可能包含未转义的控制字符(笔记 content 中的原始换行符),建议用支持容错解析的 JSON 库处理,或在解析前对 content 字段做预处理。
⚠️
id、next_cursor、parent_id均为 int64,JavaScript 环境必须在JSON.parse前做字符串化处理(见「笔记 ID 处理规则」)。 务必用字符串保存这些值,不要做数值运算,后续调详情、加知识库等操作直接透传字符串即可。
笔记类型 note_type:
plain_text - 纯文本img_text - 图片笔记link - 链接笔记audio - 即时录音meeting - 会议录音local_audio - 本地音频internal_record - 内录音频class_audio - 课堂录音recorder_audio - 录音卡长录recorder_flash_audio - 录音卡闪念text
GET /open/api/v1/resource/note/detail?id={note_id}
参数:
id (int64, 必填) - 笔记 IDimage_quality (string, 可选) - 图片质量,传 original 返回正文中图片的原图链接(无压缩)新增字段:
note_id (string) - 笔记 ID 的字符串格式,便于 AI Agent 解析,避免 int64 精度问题children_ids (string[]) - 子笔记 ID 列表(字符串格式),仅当有子笔记时返回图片附件: attachments[] 中每个图片包含:
url - 缩略图 URL(720px 压缩)original_url - 原图 URL(无压缩,适合需要高清图的场景)正文原图:传 image_quality=original 时, content 中的 markdown 图片链接会返回原图(去掉 OSS 压缩参数)。
详情独有字段(列表不返回): audio.original、 audio.play_url、 audio.duration、 web_page.content、 web_page.url、 web_page.excerpt、 attachments[]、 children_ids。详见 references/api-details.md。
text
POST /open/api/v1/resource/note/save
Content-Type: application/json
仅支持新建,不支持编辑。
请求体:
json
{
"title": "笔记标题",
"content": "Markdown 内容",
"note_type": "plain_text",
"tags": ["标签1", "标签2"],
"parent_id": 0,
"link_url": "https://...",
"image_urls": ["https://..."]
}
plain_text:同步返回,立即完成link / img_text:返回 task_id, 必须轮询 /task/progress详细字段说明见 references/api-details.md。
text
POST /open/api/v1/resource/note/update
Content-Type: application/json
请求体:
json
{
"note_id": 123456789,
"title": "新标题",
"content": "新的 Markdown 内容",
"tags": ["标签1", "标签2"]
}
参数说明:
note_id (int64, 必填) - 要更新的笔记 IDtitle (string, 可选) - 新标题,不传则不更新content (string, 可选) - 新内容,不传则不更新tags (string[], 可选) - 新标签列表, 替换 原有标签(不传则保持原标签)⚠️ 至少需要传 title、content、tags 中的一个,否则返回错误。
⚠️ 仅支持 plain_text 类型笔记,链接笔记、图片笔记等暂不支持更新。
text
POST /open/api/v1/resource/note/task/progress
Content-Type: application/json
请求体:
json
{"task_id": "task_abc123xyz"}
返回:
⚠️ note_id 是 int64,JavaScript 环境须按「笔记 ID 处理规则」做字符串化,拿到后直接当字符串透传。
建议 10-30 秒间隔轮询,直到 success 或 failed。
text
POST /open/api/v1/resource/note/delete
Content-Type: application/json
请求体:
json
{"note_id": 123456789}
笔记移入回收站,需要 note.content.trash scope。
⚠️ 必须遵循的体验流程:链接笔记和图片笔记是异步生成的,必须按以下方式与用户沟通。
步骤 1:提交任务
text
POST /open/api/v1/resource/note/save {note_type:"link", link_url:"https://..."}
返回 task_id 后, 立即发消息给用户:
✅ 链接已保存,正在抓取原文和生成总结,稍后告诉你结果...
⚠️ 重复链接处理:若响应中包含
duplicate_count > 0且没有task_id,说明该链接已存在于你的笔记中,无需轮询,直接告知用户「该链接已存在于你的笔记中」。
步骤 2:后台轮询(10-30 秒间隔)
text
POST /open/api/v1/resource/note/task/progress {task_id} → 直到 status=success/failed
步骤 3:任务完成后, 调详情接口展示价值
text
GET /open/api/v1/resource/note/detail?id={note_id}
然后发第二条消息,包含具体内容:
✅ 笔记生成完成!
- 📄 原文:已保存 {web_page.content 字数} 字
- 📝 总结:{content 内容,即 AI 生成的摘要}
- 🔗 来源:{web_page.url}
步骤 1-3:获取凭证 → 上传 OSS → 提交任务
text
1. GET /open/api/v1/resource/image/upload_token?mime_type=jpg → 获取上传凭证
2. POST {host} 上传文件到 OSS
3. POST /open/api/v1/resource/note/save {note_type:"img_text", image_urls:[access_url]} → 返回 task_id
拿到 task_id 后, 立即发消息给用户:
✅ 图片已保存,正在识别内容,稍后告诉你结果...
步骤 4:后台轮询
text
POST /open/api/v1/resource/note/task/progress {task_id} → 直到 status=success/failed
步骤 5:任务完成后, 调详情接口展示价值
text
GET /open/api/v1/resource/note/detail?id={note_id}
然后发第二条消息:
✅ 图片笔记生成完成!
- 📝 识别内容:{content 内容}
- 🏷️ 标签:{tags}
text
GET /open/api/v1/resource/image/upload_token?mime_type=jpg&count=1
参数:
⚠️ mime_type 必须与实际文件格式一致,否则 OSS 签名失败。
返回字段说明见 references/api-details.md。
⚠️ 字段顺序必须严格遵守,否则 OSS 签名验证失败。
字段顺序: key → OSSAccessKeyId → policy → signature → callback → Content-Type → file
完整示例见 references/api-details.md。
适用场景:「搜一下」「找找我哪些笔记提到了 XX」
所需 scope: note.recall.read
text
POST /open/api/v1/resource/recall
Content-Type: application/json
请求体:
json
{
"query": "搜索关键词",
"top_k": 3
}
参数类型说明querystring, 必填搜索关键词或语义描述top_kint, 可选返回数量,默认 3,最大 10
返回结构(结果已按相关度 从高到低 排序):
json
{
"results": [
{
"note_id": "1896830231705320746",
"note_type": "NOTE",
"title": "笔记标题",
"content": "笔记内容片段",
"created_at": "2025-12-24 15:20:15"
}
]
}
适用场景:「在我的 XX 知识库搜一下 XX」
所需 scope: note.topic.recall.read
text
POST /open/api/v1/resource/recall/knowledge
Content-Type: application/json
请求体:
json
{
"topic_id": "知识库 alias id",
"query": "搜索关键词",
"top_k": 3
}
参数类型说明topic_idstring, 必填知识库 ID(alias id,来自 /knowledge/list 的 topic_id_alias)querystring, 必填搜索关键词或语义描述top_kint, 可选返回数量,默认 3,最大 10
返回结构同笔记召回。
字段说明note_id笔记 ID(string); 仅 NOTE 类型有值,其余类型均为空note_type内容类型:NOTE / FILE / BLOGGER / LIVE / URL / DEDAOtitle笔记/文档标题content相关内容片段created_at创建/发布时间(YYYY-MM-DD HH:MM:SS)page_noFILE 类型时表示文件页码,其余类型省略
后续操作:
NOTE类型可调详情接口获取全文,其余类型只能展示召回片段。
用户:「找找我哪些笔记提到了大模型 API」 →
POST /recall{ "query": "大模型 API", "top_k": 3 }
用户:「在我的 AI 学习知识库里搜一下 RAG」 → 先调
/knowledge/list找到topic_id_alias,再POST /recall/knowledge{ "topic_id": "xxx", "query": "RAG", "top_k": 3 }
text
POST /open/api/v1/resource/note/tags/add
Content-Type: application/json
请求体:
json
{
"note_id": 123456789,
"tags": ["工作", "重要"]
}
标签类型 type:
text
POST /open/api/v1/resource/note/tags/delete
Content-Type: application/json
请求体:
json
{
"note_id": 123456789,
"tag_id": "123"
}
⚠️ system 类型标签不允许删除。
text
GET /open/api/v1/resource/knowledge/list?page=1
参数:
返回:topics[], has_more, total
每个 topic 包含:
topic_id / topic_id_alias:知识库 ID
name、 description、 cover
created_at / updated_at:时间字符串(YYYY-MM-DD HH:MM:SS)
stats:统计数据
note_count:笔记数file_count:文件数blogger_count:订阅博主数live_count:已完成直播数text
POST /open/api/v1/resource/knowledge/create
Content-Type: application/json
请求体:
json
{
"name": "知识库名称",
"description": "描述",
"cover": ""
}
⚠️ 每天最多创建 50 个知识库(北京时间 00:00 重置)。
text
GET /open/api/v1/resource/knowledge/notes?topic_id=abc123&page=1
参数:
每页固定 20 条,用 has_more 判断是否有下一页。
当用户说「存到对应的知识库」或「存到相关知识库」时:
text
POST /open/api/v1/resource/knowledge/note/batch-add
Content-Type: application/json
请求体:
json
{
"topic_id": "abc123",
"note_ids": [123456789, 123456790]
}
⚠️ 每批最多 20 条。已存在的笔记会跳过。
text
POST /open/api/v1/resource/knowledge/note/remove
Content-Type: application/json
请求体:
json
{
"topic_id": "abc123",
"note_ids": [123456789]
}
text
GET /open/api/v1/resource/knowledge/bloggers?topic_id={alias_id}&page=1
参数:
每页固定 20 条,用 has_more 判断。
返回 bloggers[],每项字段:
字段说明follow_id订阅关系 ID, 查博主内容时必用account_name博主名称account_icon博主头像platform平台(如 DEDAO)account_url博主主页链接follow_time订阅时间(YYYY-MM-DD HH:MM:SS)
text
GET /open/api/v1/resource/knowledge/blogger/contents?topic_id={alias_id}&follow_id={follow_id}&page=1
参数: topic_id(知识库 AliasID)、 follow_id(博主订阅 ID)、 page(页码)
返回 contents[],关键字段: post_id_alias(详情必用)、 post_title、 post_summary。
列表不含原文,需要原文请调详情接口。完整字段见 references/api-details.md。
text
GET /open/api/v1/resource/knowledge/blogger/content/detail?topic_id={alias_id}&post_id={post_id_alias}
参数: topic_id(知识库 AliasID)、 post_id(内容 ID,来自列表的 post_id_alias)
返回完整内容,包含 post_media_text(原文)。
text
GET /open/api/v1/resource/knowledge/lives?topic_id={alias_id}&page=1
参数: topic_id(知识库 AliasID)、 page(页码)
返回 lives[],关键字段: live_id(详情必用)、 name、 status。
只返回已结束且 AI 已处理完的直播。 完整字段见 references/api-details.md。
text
GET /open/api/v1/resource/knowledge/live/detail?topic_id={alias_id}&live_id={live_id}
参数: topic_id(知识库 AliasID)、 live_id(直播 ID,来自列表)
返回完整内容,包含 post_summary(AI 摘要)和 post_media_text(原文转写)。
详细错误码和限流结构见 references/api-details.md
json
{
"success": false,
"error": {
"code": 10001,
"message": "unauthorized",
"reason": "not_member"
},
"request_id": "xxx"
}
错误码说明处理方式10001鉴权失败检查 API Key 和 Client ID10201非会员引导开通: https://www.biji.com/checkout?product_alias=6AydVpYeKl20001笔记不存在确认笔记 ID 正确42900限流降低频率,查看 rate_limit 字段50000系统错误稍后重试
当用户要求「配置 Get笔记」「连接 Get笔记」时,使用此流程自动获取凭证。
code 和 verification_uriapi_key 和 client_idtext
POST https://openapi.biji.com/open/api/v1/oauth/device/code
Content-Type: application/json
请求体:
json
{
"client_id": "cli_a1b2c3d4e5f6789012345678abcdef90"
}
⚠️ client_id 固定为
cli_a1b2c3d4e5f6789012345678abcdef90,这是 Get笔记 为 OpenClaw 预注册的应用。
返回:
json
{
"success": true,
"data": {
"code": "abc123...",
"verification_uri": "https://biji.com/openapi/oauth/authorize?code=abc123...",
"user_code": "ABCD-1234",
"expires_in": 600,
"interval": 5
}
}
字段说明code授权码,轮询时使用verification_uri授权链接, 发送给用户点击user_code确认码, 必须展示给用户核对expires_in授权码有效期(秒),默认 600interval建议轮询间隔(秒),默认 5
将 verification_uri 和 user_code 发送给用户:
🔗 请点击链接完成授权:
{verification_uri}
⚠️ 请核对确认码:
{user_code}授权页面会显示确认码,请确保与上面一致后再点击授权。授权码 10 分钟内有效。
安全提醒: user_code 用于防止钓鱼攻击。用户在授权页面看到的确认码必须与 Agent 展示的一致,不一致请勿授权。
发送后立即启动后台轮询(步骤 3)。
发送授权链接给用户后, 立即在后台启动轮询,无需等待用户回复。
text
POST https://openapi.biji.com/open/api/v1/oauth/token
Content-Type: application/json
请求体:
json
{
"grant_type": "device_code",
"client_id": "cli_a1b2c3d4e5f6789012345678abcdef90",
"code": "{code}"
}
轮询策略:
推荐:使用轮询脚本
bash
# 方式 1:后台轮询 + process poll 等待结果(OpenClaw 推荐)
# exec 启动后台任务,然后用 process poll 等待完成
exec: python scripts/oauth_poll.py "{code}"
background: true
# 用 process poll 等待结果(最长等 10 分钟)
process: poll
sessionId: {上一步返回的 sessionId}
timeout: 600000
# 方式 2:简单等待(适合短时间)
result=$(python scripts/oauth_poll.py "{code}")
api_key=$(echo "$result" | jq -r '.api_key')
client_id=$(echo "$result" | jq -r '.client_id')
脚本会自动处理各种状态,成功时输出 JSON,失败时输出错误到 stderr。
轮询响应状态:
响应说明处理方式{"msg": "authorization_pending"}用户尚未操作继续轮询{"msg": "rejected"}用户拒绝授权停止轮询,告知用户已拒绝{"msg": "expired_token"}授权码已过期停止轮询,提示重新发起{"msg": "already_consumed"}授权码已使用停止轮询,可能已配置成功{"api_key": "...", "client_id": "...", ...}授权成功进入步骤 4
授权成功返回:
json
{
"success": true,
"data": {
"client_id": "cli_a1b2c3d4e5f6789012345678abcdef90",
"api_key": "gk_live_xxx",
"key_id": "abc123",
"expires_at": 1742000000
}
}
字段说明client_id应用 IDapi_keyAPI Key, 写入配置文件key_idKey ID(管理用)expires_at过期时间戳(Unix 秒),有效期 1 年
将获取的凭证写入 ~/.openclaw/openclaw.json:
json
{
"skills": {
"entries": {
"getnote": {
"apiKey": "{api_key}",
"env": {
"GETNOTE_CLIENT_ID": "{client_id}"
}
}
}
}
}
告知用户:
✅ Get笔记 配置完成!
- API Key 有效期至 {expires_at 格式化日期}
- 现在可以使用「记一下」「查笔记」等功能了
- 如需注销授权,请访问: https://www.biji.com/openapi?tab=keys