跳到主要内容

接口参考:记录

四个接口:

方法路径用途
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​

路径参数​

参数类型说明
taskIdinteger任务 ID,≥1

查询参数​

参数类型默认说明
syncstringnewestnewest / delta / backfill
orderstring见下asc / desc
cursorstring-上一页 nextCursor;与 sinceId 互斥
sinceIdinteger0只返回 kds_id 大于该值
limitinteger201~500;服务端默认夹取到 100
fieldsstring-逗号分隔字段投影
formatstringjsonjson / md / text
contentMaxCharsinteger200001000~200000
statusinteger0发布状态位;0=全部
includestring-只接受 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 + sinceId400 invalid_param
sync=delta/backfill 且无 cursor/sinceId400 invalid_param
sync=newest + order=asc400 invalid_param
sync=delta/backfill + order=desc400 invalid_param

错误​

HTTPcode场景
400invalid_param参数组合非法
401unauthorizedKey 无效
404not_found任务不存在
429rate_limited限流
503service_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​

查询参数​

参数类型必填默认说明
sinceIdinteger是-≥1;只返回 kds_id 大于该值
limitinteger否1001~500

响应 data​

{
"changes": [
{"id": 1024, "updatedAt": 1760000000000, "changeType": "created"}
],
"nextSinceId": 1024,
"hasMore": false
}
  • 只返回 ID、更新时间、变更类型;
  • 当前只有 created;
  • 不返回正文;需要正文再按 ID 取 records。

错误​

HTTPcode场景
400invalid_paramsinceId 缺失或 <1
401unauthorizedKey 无效
404not_found任务不存在
429rate_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。

相关​