API 使用文档
快速上手 Rnote API,从注册到发起第一个请求
开始之前
认证方式
所有 API 请求需要通过 X-API-Key Header 传递 API Key 进行认证。
# 在 HTTP Header 中传递 API Key
curl -X 'GET' \
'https://rnote.dev/api/v2/crawler/note/image?note_id=697c0eee000000000a03c308' \
-H 'accept: application/json' \
-H 'X-API-Key: sk-5bc4****************************e175'
第一个请求
以获取图文笔记详情为例:
curl -X 'GET' \
'https://rnote.dev/api/v2/crawler/note/image?note_id=697c0eee000000000a03c308' \
-H 'accept: application/json' \
-H 'X-API-Key: sk-5bc4****************************e175'
import requests
API_KEY = "sk-5bc4****************************e175"
BASE_URL = "https://rnote.dev/api/v2/crawler"
response = requests.get(
f"{BASE_URL}/note/image",
params={"note_id": "697c0eee000000000a03c308"},
headers={
"X-API-Key": API_KEY,
"accept": "application/json",
},
)
data = response.json()
print(data)
const API_KEY = "sk-5bc4****************************e175";
const BASE_URL = "https://rnote.dev/api/v2/crawler";
const res = await fetch(
`${BASE_URL}/note/image?note_id=697c0eee000000000a03c308`,
{
headers: {
"X-API-Key": API_KEY,
"accept": "application/json",
},
}
);
const data = await res.json();
console.log(data);
笔记接口
/note/image
获取图文笔记详情,返回笔记内容、图片列表、作者信息、互动数据等
note_id (必填)
/note/video
获取视频笔记详情,返回视频播放地址、封面图、作者信息等
note_id (必填)
/note/mixed
获取首页推荐流笔记详情,留空 note_id 返回推荐流数据
note_id (可选)
/note/comments
获取笔记评论列表,支持分页和多种排序方式
note_id (必填) · cursor · index · sort_strategy (default / latest_v2 / like_count)
/note/sub_comments
获取笔记二级评论(子评论/回复),游标分页
note_id (必填) · comment_id (必填) · cursor · index · num
/note/metrics
上报笔记指标(点赞、收藏、分享等互动数据)
note_id · report_type · target_count
用户接口
/user/info
获取用户信息,返回用户昵称、头像、简介、粉丝数等
user_id (必填)
/user/posted
获取用户发布的笔记列表,支持游标分页
user_id (必填) · cursor · num
/user/faved
获取用户收藏的笔记列表,支持游标分页
user_id (必填) · cursor · num
搜索接口
/search/notes
搜索笔记,支持排序和筛选
keyword (必填) · page · sort (general / time_descending / popularity_descending) · note_type (0=全部 / 1=视频 / 2=图文)
/search/users
搜索用户
keyword (必填) · page
/search/images
搜索图片
keyword (必填) · page
/search/products
搜索商品
keyword (必填) · page · sort_by · source
/search/groups
搜索群聊
keyword (必填) · page
商品接口
/product/detail
获取商品详情
product_id (必填)
/product/review/overview
获取商品评论总览
product_id (必填)
/product/reviews
获取商品评论列表,支持游标分页
product_id (必填) · cursor · sort_type
/product/recommendations
获取商品推荐列表
product_id (必填) · cursor
话题接口
/topic/info
获取话题详情
topic_id (必填)
/topic/feed
获取话题下的笔记列表,支持游标分页
topic_id (必填) · cursor · sort_by
创作灵感
/creator/inspiration/feed
获取推荐灵感列表
cursor · num
/creator/hot/inspiration/feed
获取热点灵感列表
cursor · num
响应格式
所有 V2 爬虫接口(/api/v2/crawler/*)使用统一的 JSON 响应结构:
成功响应
{
"success": true,
"data": { /* 业务数据,结构因接口而异 */ },
"billed": true,
"debug_id": "a1b2c3d4",
"debug_info": "gAAAAABm... (Fernet 密文,仅管理员可解)"
}
失败响应
{
"success": false,
"data": null,
"error": "请求过于频繁,请稍后重试",
"retry_after": 5.0,
"billed": false,
"debug_id": "a1b2c3d4",
"debug_info": "gAAAAABm... (Fernet 密文,仅管理员可解)"
}
字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
success |
bool | 业务成败标志(与 HTTP 状态码语义一致) |
data |
object | null | 业务数据;失败时为 null |
error |
string | null | 通用错误提示(五类固定文案,对外脱敏);成功时为 null |
retry_after |
float | null | 限流/暂时不可用时的建议等待秒数;与 HTTP Retry-After 头一致 |
billed |
bool | 本次请求是否扣费(只在业务成功时扣费,任何失败不扣费) |
debug_id |
string | null | 8 字符随机关联码,用于在 support ticket 里引用本次请求(与节点/账号无任何关联) |
debug_info |
string | null | 加密的调试信息(仅管理员可解密查看节点/上游错误码等内部细节) |
关于 debug_id 和 debug_info
报告问题时附上响应里的 debug_id(短码)或完整 debug_info(密文)能显著加速排查。debug_info 内含节点 ID、上游错误码、trace ID 等内部细节,但已加密 —— 用户端无法解出明文,仅服务端管理员可解密。
错误码
中间件层(鉴权 / 限流 / 计费)
这些状态码在请求到达业务逻辑前就会返回,与具体接口无关。
| HTTP 状态码 | 说明 | 处理方式 |
|---|---|---|
401 |
未提供或无效的 API Key | 检查 X-API-Key Header |
402 |
余额不足 | 到管理后台充值余额 |
403 |
无权访问该接口 | 检查 API Key 权限范围 |
429 |
每用户/每 IP 请求频率超限 | 降低请求频率,稍后重试 |
业务接口层(V2 爬虫)
V2 爬虫接口失败响应使用标准 4xx/5xx 状态码 + Retry-After 头。请同时检查 HTTP 状态码和 body.success。
| HTTP 状态码 | 触发场景 | 处理方式 |
|---|---|---|
400 |
请求参数不合法 | 检查参数格式(不要重试) |
404 |
接口不存在 | 检查 URL 路径 |
429 |
请求被节流 / 上游频率限制 | 按 Retry-After 头等待后重试 |
500 |
服务器内部错误(兜底) | 稍后重试;持续失败请附上 debug_id 联系支持 |
502 |
上游小红书拒绝 / 风控 / RPC 故障 | 稍后重试(换参数通常无效) |
503 |
服务暂时不可用(节点池耗尽 / 启动中) | 按 Retry-After 头等待后重试 |
504 |
请求链路超时 | 稍后重试 |
客户端错误处理示例
推荐写法 —— 同时检查 HTTP 状态码和 body.success,并在异常日志里附上 debug_id:
import requests
resp = requests.get(
"https://rnote.dev/api/v2/crawler/user/info",
headers={"X-API-Key": "sk-..."},
params={"user_id": "..."},
timeout=20,
)
body = resp.json()
# 双重判断: HTTP status 优先, body.success 兜底
if resp.status_code >= 400 or not body.get("success"):
error = body.get("error", "未知错误")
debug_id = body.get("debug_id", "n/a")
retry_after = body.get("retry_after")
print(f"请求失败 [{debug_id}]: {error}", end="")
if retry_after:
print(f" (建议 {retry_after}s 后重试)")
# 联系支持时附上 debug_id 或完整 debug_info
else:
data = body["data"]
# 处理业务数据 ...
计费说明
按请求计费
仅成功请求 (HTTP 2xx) 扣费,失败请求不计费。每个 API 端点独立定价。
余额不足
当余额不足以支付当前请求的费用时,返回 HTTP 402 错误码,请求不会被执行。
交易记录
所有扣费记录可在管理后台「计费」页面查看,包含时间、端点、金额等详情。