接口参考:记录
四个接口:
| 方法 | 路径 | 用途 |
|---|---|---|
| GET | /api/v2/tasks/{taskId}/records | 任务记录 |
| GET | /api/v2/records | 默认文章库记录 |
| GET | /api/v2/tasks/{taskId}/changes | 任务增量变更 |
| GET | /api/v2/changes | 默认文章库增量变更 |
scope:data:read
GET /api/v2/tasks/{taskId}/records
路径参数
| 参数 | 类型 | 说明 |
|---|---|---|
taskId | integer | 任务 ID,≥1 |
查询参数
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
sync | string | newest | newest / delta / backfill |
order | string | 见下 | asc / desc |
cursor | string | - | 上一页 nextCursor;与 sinceId 互斥 |
sinceId | integer | 0 | 只返回 kds_id 大于该值 |
limit | integer | 20 | 1~500;服务端默认夹取到 100 |
fields | string | - | 逗号分隔字段投影 |
format | string | json | json / md / text |
contentMaxChars | integer | 20000 | 1000~200000 |
status | integer | 0 | 发布状态位;0=全部 |
include | string | - | 只接受 html;当前不返回 HTML,只加 warning |
order 规则:newest 未传时默认 desc,其余默认 asc;newest 只允许 desc,
delta/backfill 只允许 asc。
响应 data
{
"taskId": 738590,
"records": [
{
"_id": 1024,
"_url": "https://doc.keydatas.com/getting-started/wangzhan-wenzhang-caiji.html",
"_createdAt": 1760000000000,
"_updatedAt": 1760000000000,
"title": "文章标题",
"_warnings": []
}
],
"nextCursor": "MTAyNHwxNzYwMDAwMDAwMDAw",
"hasMore": true,
"sync": "delta",
"format": "json",
"tokenEstimate": 3200,
"estimated": true,
"warnings": []
}
说明:
- 没有
total字段; taskId是解析到的任务 ID;estimated=true表示 token 是估算值;warnings是页级降级说明。
校验规则
| 请求 | 结果 |
|---|---|
cursor 与 sinceId 同时传 | 400 invalid_param |
sync=newest + sinceId | 400 invalid_param |
sync=delta/backfill 且无 cursor/sinceId | 400 invalid_param |
sync=newest + order=asc | 400 invalid_param |
sync=delta/backfill + order=desc | 400 invalid_param |
错误
| HTTP | code | 场景 |
|---|---|---|
| 400 | invalid_param | 参数组合非法 |
| 401 | unauthorized | Key 无效 |
| 404 | not_found | 任务不存在 |
| 429 | rate_limited | 限流 |
| 503 | service_unavailable | 内容服务/依赖不可用 |
示例
# 最新 20 条
curl "https://open.keydatas.com/api/v2/tasks/738590/records?sync=newest&limit=20" \
-H "Authorization: Bearer $KEYDATAS_API_KEY"
# 增量 + 字段投影 + Markdown
curl "https://open.keydatas.com/api/v2/tasks/738590/records?sync=delta&sinceId=1000&limit=50&fields=title,pubDate&format=md&contentMaxChars=8000" \
-H "Authorization: Bearer $KEYDATAS_API_KEY"
GET /api/v2/records
默认文章库记录,参数同上(不含 taskId),并额外支持 include、status。
固定只返回最新版本。
未初始化时返回 404 default_task_not_initialized。
curl "https://open.keydatas.com/api/v2/records?sync=newest&limit=10&format=md" \
-H "Authorization: Bearer $KEYDATAS_API_KEY"
GET /api/v2/tasks/{taskId}/changes
查询参数
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
sinceId | integer | 是 | - | ≥1;只返回 kds_id 大于该值 |
limit | integer | 否 | 100 | 1~500 |
响应 data
{
"changes": [
{"id": 1024, "updatedAt": 1760000000000, "changeType": "created"}
],
"nextSinceId": 1024,
"hasMore": false
}
- 只返回 ID、更新时间、变更类型;
- 当前只有
created; - 不返回正文;需要正文再按 ID 取 records。
错误
| HTTP | code | 场景 |
|---|---|---|
| 400 | invalid_param | sinceId 缺失或 <1 |
| 401 | unauthorized | Key 无效 |
| 404 | not_found | 任务不存在 |
| 429 | rate_limited | 限流 |
curl "https://open.keydatas.com/api/v2/tasks/738590/changes?sinceId=1000&limit=100" \
-H "Authorization: Bearer $KEYDATAS_API_KEY"
GET /api/v2/changes
默认文章库的增量变更,参数同上。sinceId 必填 ≥1;未初始化时 404。