使用 ListDocuments 接口分页查询知识库下的文档列表。
前提条件
已创建 AgentStorage 实例且状态为
normal,并获取实例访问地址(endpoint)和实例名。已创建 API Key。
待查询的知识库已存在。
请求参数
参数 | 类型 | 说明 |
| string | 知识库名称(必填) |
| list<string> | 子空间列表,最多 10 个。开启 subspace 时必填 |
| int | 返回数量。默认为 10,最大 1000 |
| string | 翻页 token |
请求示例
使用 API Key 认证时,通过 x-ots-instancename 和 x-ots-apikey 请求头传入实例名和 API Key。
curl -X POST https://<endpoint>/ListDocuments \
-H "x-ots-instancename: <instance-name>" \
-H "x-ots-apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"knowledgeBaseName": "product_docs_kb",
"subspace": ["default"],
"maxResults": 10
}'响应
{
"code": "SUCCESS",
"data": {
"documentDetails": [
{
"docId": "fc6ed97f-example-4doc-9b73-bf4a7d67ab65",
"ossKey": "oss://example-bucket/docs/kb_doc.txt",
"subspace": "_default",
"chunkNum": 1,
"status": "completed",
"createdAt": 1787636583092,
"eTag": "6227CEC56ABFAF47135E4C033FF24C98",
"updatedAt": 1787636583092, "metadata": {"author": "张三", "date": "2026-01-22 10:00:59", "score": 80}"updatedAt": 1787636583092
}
],
"nextToken": ""
},
"message": "succeed"
}该文章对您有帮助吗?