获取知识库列表

通过 OpenAPI 获取通义灵码知识库列表。

适用版本

企业专属版、企业标准版

服务接入点

获取服务接入点,替换 API 请求语法中的 {domain}

授权信息

产品

资源

所需权限

通义灵码

知识库

只读

请求语法

GET https://{domain}/oapi/v1/lingma/organizations/{organizationId}/knowledgeBases

请求说明

企业标准版

查询组织下的全部知识库

curl -X 'GET' \
  'https://openapi-rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

知识库名称模糊查询

curl -X 'GET' \
  'https://openapi-rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases?query=t' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

根据场景类型查询知识库

curl -X 'GET' \
  'https://openapi-rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases?sceneType=chat' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

企业专属版

查询组织下的全部知识库

curl -X 'GET' \
  'https://test-domain-***.rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

知识库名称模糊查询

curl -X 'GET' \
  'https://test-domain-***.rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases?query=t' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

根据场景类型查询知识库

curl -X 'GET' \
  'https://test-domain-***.rdc.aliyuncs.com/oapi/v1/lingma/organizations/6826e1d0516a9f85a08c****/knowledgeBases?sceneType=chat' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

请求头(Headers)

x-yunxiao-token string (必选)

个人访问令牌。您可参考个人访问令牌获取。

示例:pt-0fh3****0fbG_35af****0484。

请求参数

organizationId string (必选)

所属组织ID。您可以前往组织管理后台基本信息页面获取organizationId

query string (可选)

知识库名称模糊查询。

sceneType string (可选)

场景类型,支持如下两种场景类型:

  • chat:智能问答场景。

  • complement:行间生成场景,此字段为空则获取全部场景类型的知识库列表。

orderBy string (可选)

排序列,支持如下排序字段:

  • name:知识库名称。

  • sceneType:知识库场景类型。

  • size:知识库大小。

  • fileCount:知识库内文件数目。

  • lastActivityTime:知识库上次活跃时间。

  • gmtCreate:知识库创建时间。

sort string (可选)

排序顺序:

  • desc:倒序。

  • asc:正序。

userId string (可选)

用户 ID:当传入用户 id 时,只会返回此用户有权限的知识库列表;当此字段为空时,获取全部的知识库列表。

page integer (可选)默认值为1

当前页。

perPage integer (可选)默认值为20

每页数据条数的最大值,取值范围:[1,20]

返回参数

返回示例

[
    {
        "accessLevel": 10,
        "creator": {
            "avatarUrl": "https://tcs-devops.aliyuncs.com/thumbnail/113iaf62a4481af4cd44ad46d8c3e9b55851/w/100/h/100",
            "displayName": "fangqian_testcloud_com",
            "id": "66a6f60e368d88cff5a513fc",
            "userName": "test"
        },
        "description": "",
        "fileCount": 0,
        "gmtCreate": 1749712990396,
        "gmtModified": 1749712990396,
        "id": "7d9800958eabaa982de687c8",
        "lastActivityTime": 1749712990396,
        "memberCount": 1,
        "name": "test",
        "organizationId": "6826e1d0516a9f85a08cb522",
        "sceneType": "chat",
        "size": "0 B",
        "state": "disable"
    }
]

accessLevel integer

知识库可见性,目前包含以下两种:

  • 0:代表私有知识库。

  • 10:代表公开知识库。

creator object

知识库创建者。

属性

avatarUrl string

创建者头像。

displayName string

创建者登录名称。

id string

创建者 ID。

userName string

创建者昵称。

description string

描述。

fileCount integer

知识库内文件数目。

gmtCreate integer

知识库创建时间。

gmtModified integer

知识库更新时间。

id string

知识库 ID。

lastActivityTime integer

知识库上次活跃时间。

memberCount integer

知识库成员数目。

name string

知识库名称。

organizationId string

知识库所属组织 ID。

sceneType string

知识库场景类型。目前包含以下两种:

  • chat:智能问答场景。

  • complement:行间生成场景。

size string

知识库大小。

state string

知识库状态,目前包含以下两种:

  • enable:知识库已激活。

  • disable:知识库未激活。

响应头

参数

描述

示例值

x-next-page

下一页

1

x-page

当前页

1

x-per-page

每页大小

20

x-prev-page

前一页

1

x-total

总数

9

x-total-pages

总分页数

1

错误码

访问错误码中心查看 API 相关错误码。