查询问题分类目录

查询问题分类目录

按一级分类分页,返回每个一级分类及其全部直接子分类,包括停用项。

子分类的 enabled 控制它是否参与新问题的自动匹配。停用后,分类目录仍返回该子分类及 enabled: false,历史问题已命中的分类也会保留。

请求方式

GET

调用地址

https://api-sg.gptbots.ai/v1/question-categories

调用鉴权

使用当前 Agent 的 API Key。项目套餐需同时支持 API 集成和问题识别。请选择组织所在数据中心的地址。 API 概述

调用频率

与项目的其他统计 API 共享每分钟请求额度,超限返回 40008。

请求

请求示例

curl -X GET "https://api-sg.gptbots.ai/v1/question-categories?page=1&page_size=20" \ -H "Authorization: Bearer your_apikey"
                      
                      curl -X GET "https://api-sg.gptbots.ai/v1/question-categories?page=1&page_size=20" \
  -H "Authorization: Bearer your_apikey"

                    
此代码块在浮窗中显示

请求头

字段 类型 描述
Authorization string Bearer your_apikey

请求参数

字段 类型 必填 描述
page int 否 页码,从 1 开始,默认 1。
page_size int 否 每页条数,范围 1~100,默认 20。

响应

响应示例

{ "total": 1, "page": 1, "page_size": 20, "items": [ { "id": "66a1b2c3d4e5f60001000001", "name": "售后服务", "level": 1, "parent_id": null, "enabled": true, "children": [ { "id": "66a1b2c3d4e5f60001000002", "name": "退款进度", "level": 2, "parent_id": "66a1b2c3d4e5f60001000001", "enabled": true, "description": "查询退款何时到账", "children": [] } ] } ] }
                      
                      {
  "total": 1,
  "page": 1,
  "page_size": 20,
  "items": [
    {
      "id": "66a1b2c3d4e5f60001000001",
      "name": "售后服务",
      "level": 1,
      "parent_id": null,
      "enabled": true,
      "children": [
        {
          "id": "66a1b2c3d4e5f60001000002",
          "name": "退款进度",
          "level": 2,
          "parent_id": "66a1b2c3d4e5f60001000001",
          "enabled": true,
          "description": "查询退款何时到账",
          "children": []
        }
      ]
    }
  ]
}

                    
此代码块在浮窗中显示

成功响应

字段 类型 描述
total long 一级分类总数
page int 页码,从 1 开始,默认 1。
page_size int 每页条数,范围 1~100,默认 20。
items array 本页记录
id string 分类 ID
name string 分类名称
level int 层级:1 为一级,2 为二级。
parent_id string / null 父分类 ID;一级为 null。
enabled boolean 是否启用
description string / null 二级分类描述,最多 100 个字符;一级分类不可传。
children array 直接子分类;叶节点为空数组。

失败响应

字段 类型 描述
code int 错误码。
message string 错误描述信息。

错误码

Code Message
40000 参数无效
40008 超过统计 API 每分钟额度
40100 当前 Agent 无权操作目标资源
40101 缺少 Authorization 请求头
40127 Agent API Key 无效
20055 Agent 未启用 API
40353 套餐未开通所需权益
50000 服务内部错误