跳到主要内容

接口参考:导出

POST /api/v2/tasks/{taskId}/exports​

创建任务导出。

scope:export

请求头​

头必填说明
Idempotency-Key是重试复用同一个值

路径参数​

参数类型说明
taskIdinteger任务 ID

请求体​

字段类型必填说明
formatstring是xlsx / csv / json / txt / sql
fieldsstring[]否必须是任务真实字段;不传=全部
statusinteger否只支持 0
filters.sinceIdinteger否只导出 kds_id >= sinceId 的数据

响应 data​

{
"id": "8f3a2c1d4e5b6a7c8d9e0f1a2b3c4d5e",
"status": "pending",
"format": "xlsx",
"expiresAt": 0,
"rowCount": 0,
"truncated": false
}

创建时 downloadUrl 不存在;completed 后才返回。

错误​

HTTPcode场景
400invalid_paramformat 非法、fields 不存在、filters 含不支持 key、status≠0
401unauthorizedKey 无效
403forbiddenFree 套餐、任务不属于当前账号、套餐限制
404not_found任务不存在
409conflict幂等键冲突
429rate_limited导出队列满
503service_unavailable导出未开放

示例​

curl -X POST https://open.keydatas.com/api/v2/tasks/738590/exports \
-H "Authorization: Bearer $KEYDATAS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"format":"xlsx","fields":["title","pubDate","author"],"filters":{"sinceId":1}}'

POST /api/v2/exports​

默认文章库导出。Body 同上;未指定 fields 时排除 content。

scope:export

错误​

HTTPcode场景
400invalid_param参数错误
403forbiddenFree 套餐、套餐限制
404default_task_not_initialized默认文章库未初始化
429rate_limited队列满
503service_unavailable导出未开放
curl -X POST https://open.keydatas.com/api/v2/exports \
-H "Authorization: Bearer $KEYDATAS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"format":"json","filters":{"sinceId":1}}'

GET /api/v2/exports/{exportId}​

查询导出状态与下载地址。

scope:export

路径参数​

参数类型说明
exportIdstring导出 ID(32 位 hex)

响应 data​

{
"id": "8f3a2c1d4e5b6a7c8d9e0f1a2b3c4d5e",
"status": "completed",
"format": "xlsx",
"downloadUrl": "https://open.keydatas.com/openapi/download/export?token=...",
"expiresAt": 1760604800000,
"rowCount": 18342,
"truncated": false
}

字段:

字段说明
statuspending / running / completed / failed / expired
downloadUrl仅 completed 且未过期时存在;签名链接,不要加鉴权头
expiresAt下载链接过期时间,Unix 毫秒
rowCount实际行数
truncated是否触达单次行数上限
error失败原因(仅 failed)

错误​

HTTPcode场景
401unauthorizedKey 无效
404not_found导出不存在/不属于当前账号/已清理
503service_unavailable导出未开放
curl https://open.keydatas.com/api/v2/exports/8f3a2c1d4e5b6a7c8d9e0f1a2b3c4d5e \
-H "Authorization: Bearer $KEYDATAS_API_KEY"

相关​