查询知识库文档列表
更新时间:2025-08-19
POST
https://qianfan.baidubce.com/v2/knowledgeBase?Action=DescribeDocuments
该接口用于查询指定知识库中的文档列表。
权限说明
调用本API,需使用API Key鉴权方式。Authorization的值为Bearer <API Key>。获取API Key流程,请查看授权。
请求参数
Headers 参数
除公共头域外,无其它特殊头域
Body 参数
knowledgeBaseId
string
知识库ID
必选
marker
string
起始位置,知识库文档id
可选
maxKeys
integer
数据大小,默认10,最大值100
可选
keyword
string
搜索关键字
可选
请求结构
POST /v2/knowledgeBase?Action=DescribeDocuments HTTP/1.1
HOST: qianfan.baidubce.com
Authorization: Bearer <AppBuilder API Key>
{
"knowledgeBaseId": "知识库id",
"marker": "知识库文档id",
"maxKeys": 10,
"keyword": "医疗卫生常识"
}
示例代码
curl
curl --location --request POST 'https://qianfan.baidubce.com/v2/knowledgeBase?Action=DescribeDocuments' \
--header 'Authorization: Bearer <API Key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"knowledgeBaseId": "ce27cf70-9287-4b60-82c0-7beba1537ba0",
"marker": "marker_id",
"maxKeys": 10,
"keyword": "医疗卫生常识"
}'
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
data
array
Document 对象列表
必选
显示子属性
隐藏子属性
items
object {7}
显示子属性
隐藏子属性
id
string
id
必选
meta
object {5}
source、fileId
必选
显示子属性
隐藏子属性
url
string
原文件下载链接
可选
fileId
string
上传文档id。当source值为url时,该值为null
可选
source
string
来源。 枚举值: upload_file:文本文档数据 datatable:表格型知识数据 url:网页数据
必选
file_size
integer
文件大小,单位bytes
可选
mime_type
string
文件类型,目前支持doc/txt/docx/pdf/ppt/pptx/xlsx/xls/csv/json这几种文件类型。 如果是通过url方式导入的文档,该值为url
可选
name
string
上传时的文档名
必选
enabled
boolean
是否可用
必选
createdAt
string
创建时间, UTC时间格式
必选
wordCount
integer
字数。表格型文件暂不支持字数读取。
必选
displayStatus
string
文档上传后的状态。
枚举值:
queuing:排队中
notConfigured:数据待配置
paused:处理暂停
parsing:解析中
indexing:处理中
parseError:解析失败
error:处理失败
available:可用
retrainingSegmentUnusable:重建切片中,切片不可用
retrainErrSegmentUsable:重建切片错误,旧切片可用
必选
marker
string
起始位置
必选
maxKeys
integer
本次查询包含的最大结果集数量
必选
requestId
string
requestId
必选
nextMarker
string
nextMarker下次查询的起始位置
必选
isTruncated
boolean
true表示后面还有数据,false表示已经是最后一页
必选
JSON
HTTP/1.1 200 OK
{
"requestId": "c2db9c49-5a94-429a-9814-b26272075ae9",
"marker": "",
"isTruncated": false,
"nextMarker": "3bec3435-8972-4cab-a4c6-1527da3713ed",
"maxKeys": 1,
"data": [
{
"id": "3bec3435-8972-4cab-a4c6-1527da3713ed",
"name": "医疗卫生常识.doc",
"createdAt": "2024-06-03T02:39:04Z",
"displayStatus": "available",
"wordCount": 80618,
"enabled": true,
"meta": {
"source": "upload_file",
"fileId": "86834d5d-2cea-4a42-98cf-a3ed89f3697f",
"mimeType": "doc",
"fileSize": 760872,
"url": "https://copilot-engine-bos.bj.bcebos.com/upload_files/549df68c-ff81-4768-a00f-1b34c713a59f/9523c796-191c-4add-8e.doc?authorization=bce-auth-v1%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2025-04-29T15%3A10%3A17Z15fa494755a3152fa53c0f3895b4565a20fef8a718876bd968517054752ae6",
"tags": [
{
"key": "知识",
"values": [
"医疗知识"
]
}
]
}
}
]
}
JSON
{
"requestId": "ae2225f7-1c2e-427a-a1ad-5413b762957d",
"code": "PermissionDeniedError",
"message": "没有权限"
}