查询API详情
更新时间:2026-09-20
该接口用于查询指定 API 的完整配置,包括请求匹配、后端与 Fallback、匹配规则、高级策略、消费者认证和插件绑定。
传入 MODEL_NAME 匹配规则的 ruleId 时,接口会自动定位其逻辑路由入口并返回完整逻辑 API。
请求结构
Plain Text
1POST /?action=DescribeApi HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "apiId": apiId
7}
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| apiId | String | 是 | RequestBody参数 | API ID |
返回头域
除公共头域,无其它特殊头域。
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| apiId | String | API ID |
| logicalRouteId | String | 逻辑路由 ID |
| instanceId | String | 实例 ID |
| instanceName | String | 实例名称 |
| serviceId | String | 服务 ID |
| serviceName | String | 服务名称 |
| apiType | String | API 类型 |
| routeType | String | 路由类型:HTTP_ROUTE / MODEL_ROUTE / AGENT_ROUTE |
| routeSource | String | 路由来源:CUSTOM / MODEL_SERVICE_DEFAULT / MODEL_SERVICE_MODEL_NAME |
| publishStatus | String | 发布状态:PUBLISHED / OFFLINE |
| advancedPolicy | AdvancedPolicyVO | |
| isModelServiceDefaultApi | Boolean | 是否为 Model 服务自动生成的默认 API |
| name | String | API 名称 |
| methods | List<String> | 请求方法 |
| matchType | String | 匹配类型 |
| path | String | 路径 |
| description | String | 描述 |
| fallbackEnabled | Boolean | Model 路由 Fallback 开关 |
| fallbackFirstTokenTimeoutMs | int | Model 路由 Fallback 首次响应超时时间(毫秒),0 表示不启用 |
| fallbackTriggerScope | String | Model 路由 Fallback 触发范围,仅支持 BACKEND_ERROR_ONLY |
| modelBackendStrategy | String | 后端策略:基础 API 支持 SINGLE / WEIGHT,Model 路由支持 SINGLE / MODEL_NAME / WEIGHT,Agent 路由返回 null |
| createTime | String | 创建时间 |
| updateTime | String | 修改时间 |
| headerList | List<AiGwApiHeaderUO> | 请求头列表 |
| queryList | List<AiGwApiQueryUO> | 查询参数列表 |
| backendList | List<AiGwApiBackendBindUO> | 后端配置列表,兼容返回 PRIMARY / FALLBACK |
| fallbackBackendList | List<AiGwApiBackendBindUO> | Fallback 后端列表,按 fallbackOrder 排序 |
| matchRules | List<MatchRuleUO> | 逻辑路由匹配规则 |
| urlRewrite | Boolean | 路径重写 |
| urlRewritePath | String | 路径重写:重写后的路径 |
| urlRewriteHost | String | 路径重写:重写后的 Host |
| urlRewriteType | String | 路径重写匹配类型:Exact / Prefix / Regex |
| urlRewriteRegexMatch | String | 正则重写模式,仅当重写类型为 Regex 时有值 |
| urlRewriteRegexRewrite | String | 正则重写替换表达式,仅当重写类型为 Regex 时有值 |
| retries | Boolean | 重试 |
| attempts | int | 重试次数 |
| perTryTimeout | int | 单次重试超时时间(毫秒) |
| retryOn | List<String> | 重试条件 |
| httpCodes | List<int> | 触发重试的响应状态码 |
| timeout | Boolean | 超时时间 |
| timeoutTime | int | 超时时间(毫秒) |
| priorityNumber | long | 优先级(0-9999),0 为最高优先级,默认 9999 |
| consumerAuthEnabled | Boolean | 是否开启消费者认证 |
| authorizationType | String | 消费者认证方式:API_KEY / AK_SK;未开启为空 |
| consumerAuthorizations | List<ConsumerAuthorization> | 消费者认证项列表,每项为一个消费者 + 一种凭证类型 |
| serviceConsumerAuthEnabled | Boolean | 所属服务是否开启消费者认证;API 未开启时继承服务级配置 |
| serviceAuthorizationType | String | 所属服务的消费者认证方式:API_KEY / AK_SK;服务未开启为空 |
| securityProtection | AiGwApiSecurityProtectionUO | |
| plugins | List<AiGwApiPluginUO> | 当前 API 适用且对用户可见的插件聚合结果,每个插件一条,已按插件顺序排列,包含禁用状态 |
错误码
| 错误码 | 错误描述 | HTTP状态码 | 中文解释 |
|---|---|---|---|
| MethodArgumentNotValidException | MethodArgumentNotValidException: apiId must not be blank | 400 | 必填参数缺失或格式不合法,apiId 不能为空 |
| HttpMessageNotReadable | Http Message Not Readable: JSON parse error | 400 | 请求体不是合法 JSON,无法解析,请检查 JSON 语法和字段类型 |
| ResourcePermissionDeny | Resource permission deny. | 401 | 无权限访问指定资源,请确认实例属于当前账号并使用有权限的账号凭证 |
| ApiNotExist | Api not exist. | 404 | apiId 对应的 API 不存在、不属于当前账号或已删除 |
| HttpMediaTypeException | HttpMediaTypeException: Content-Type 'text/plain' is not supported | 415 | 请求的 Content-Type 不受支持,请使用 application/json |
请求示例
Plain Text
1POST /?action=DescribeApi HTTP/1.1
2Host: bcc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
4
5{
6 "apiId": "api-a1b2c3d4"
7}
返回示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 1214cca7-4ad5-451d-9215-71cb844c0a50
3Date: Wed, 03 Dec 2014 06:42:19 GMT
4Content-Type: application/json;charset=UTF-8
5Server: BWS
6
7{
8 "apiId": "api-a1b2c3d4",
9 "logicalRouteId": "api-a1b2c3d4",
10 "instanceId": "gw-a1b2c3d4",
11 "instanceName": "生产网关",
12 "serviceId": "sg-a1b2c3d4",
13 "serviceName": "对话服务",
14 "apiType": "HTTP_ROUTE",
15 "routeType": "HTTP_ROUTE",
16 "routeSource": "CUSTOM",
17 "publishStatus": "PUBLISHED",
18 "isModelServiceDefaultApi": false,
19 "name": "对话API",
20 "methods": [
21 "POST"
22 ],
23 "matchType": "Prefix",
24 "path": "/v1/chat",
25 "description": "对外提供对话能力",
26 "modelBackendStrategy": "SINGLE",
27 "createTime": "2026-09-01T08:00:00Z",
28 "updateTime": "2026-09-08T10:30:00Z",
29 "backendList": [
30 {
31 "backendId": "bd-a1b2c3d4",
32 "backendName": "对话后端",
33 "backendRole": "PRIMARY",
34 "weight": 10000,
35 "backendType": "ip",
36 "backendTypeName": "IP"
37 }
38 ],
39 "matchRules": [],
40 "urlRewrite": false,
41 "retries": true,
42 "attempts": 1,
43 "perTryTimeout": 60000,
44 "timeout": true,
45 "timeoutTime": 60000,
46 "priorityNumber": 0,
47 "consumerAuthEnabled": false,
48 "plugins": []
49}
评价此篇文章
