查询用量接口
更新时间:2026-09-23
按检测版本查询本账号的调用量、单价与金额。本接口不计费,也不返回任何检测内容。
Plain Text
1GET /v3/skill/security/usage
- 停服/未开通账号仍可调用,便于核对用量。
请求参数(Query String)
五种查询维度互斥,任选其一;都不传时默认返回「当月」。
| 参数名 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| range | string | 可选 | 查询维度:since_open(自开通以来)、current_month(当月,默认)、since_date(自某日起至当日)、month(指定月份)、custom(指定起止时间) |
| start_date | string | 条件必填 | range=since_date 时必填,格式 YYYY-MM-DD |
| month | string | 条件必填 | range=month 时必填,格式 YYYY-MM |
| begin_date | string | 条件必填 | range=custom 时必填,格式 YYYY-MM-DD,含当日 |
| end_date | string | 条件必填 | range=custom 时必填,格式 YYYY-MM-DD,含当日 |
约束:
- 时间维度按 UTC+8 做自然日、自然月切分,与账单账期一致(本商品账单周期为「天」)。
- 单次查询时间跨度不得超过 1 年,超出返回
ParamError;range=since_open不受此限。 end_date不得早于begin_date,否则返回ParamError。- 用量数据永久保留,任意历史区间可查;
since_open返回自开通以来的真实总量。 - 五种维度互斥,同时传入冲突参数返回
ParamError;range需要的条件参数缺失返回ParamMissing。
请求示例
Plain Text
1GET /v3/skill/security/usage?range=current_month
2GET /v3/skill/security/usage?range=since_date&start_date=2026-08-01
3GET /v3/skill/security/usage?range=month&month=2026-07
4GET /v3/skill/security/usage?range=custom&begin_date=2026-07-01&end_date=2026-07-15
响应结构
JSON
1{
2 "code": "success",
3 "message": "success",
4 "ts": 1786362673044,
5 "data": {
6 "account_id": "a1b2c3d4e5f6",
7 "range": "current_month",
8 "begin_time": 1785513600,
9 "end_time": 1786377600,
10 "timezone": "UTC+8",
11 "currency": "CNY",
12 "items": [
13 { "edition": "快速检测版", "charge_item": "Skillscan", "list_price": 2, "unit": "次", "count": 120, "list_amount": 240, "pending_count": 20, "sent_count": 100 },
14 { "edition": "深度检测", "charge_item": "Skillscanpro", "list_price": 6, "unit": "次", "count": 30, "list_amount": 180, "pending_count": 0, "sent_count": 30 }
15 ],
16 "total_count": 150,
17 "total_list_amount": 420
18 }
19}
响应字段说明
| 字段名 | 类型 | 说明 |
|---|---|---|
| data.account_id | string | 本次统计归属的主账号 ID,取自签名验证结果,不取请求参数 |
| data.range | string | 本次生效的查询维度 |
| data.begin_time | number | 统计区间起始(秒级 Unix 时间戳,含) |
| data.end_time | number | 统计区间结束(秒级 Unix 时间戳,不含) |
| data.timezone | string | 统计区间切分所用时区,固定UTC+8(北京时间) |
| data.currency | string | 币种,固定CNY |
| data.items | array | 按版本分组的用量,两个版本恒定返回,无用量时count 与 list_amount 为 0 |
| data.items[].edition | string | 对外版本名称:快速检测版 / 深度检测 |
| data.items[].charge_item | string | 计费项标识:Skillscan / Skillscanpro |
| data.items[].list_price | number | 该版本牌价单价,元/次 |
| data.items[].unit | string | 计量单位,固定次。深度检测的「一次」指一个 skill |
| data.items[].count | number | 该版本计费数量。恒等于pending_count + sent_count |
| data.items[].list_amount | number | list_price × count,牌价金额 |
| data.items[].pending_count | number | 已记账、尚未进入计费系统的数量 |
| data.items[].sent_count | number | 已进入计费系统的数量(上报存在数分钟量级延迟,故可能小于count) |
| data.total_count | number | 各版本count 之和 |
| data.total_list_amount | number | 各版本list_amount 之和 |
用量统计口径
- 只统计已成功产生计费的调用;未计费调用(空结果、任务 failed、not_found、参数错误)不计入。
- 本接口统计的是已记账且会进入账单的用量(含尚未进入计费系统与已进入两部分),数字可能略多于某一时刻账单已体现的量(上报与出账有延迟),属正常。
- 因服务端内部原因最终未成功计费的用量不计入本接口,也不会出现在账单、不收费。
- 时间归属按计费窗口起始时间落日/落月,跨日窗口归入起始时间所在自然日(UTC+8)。
本接口返回仅供用量核对,不是账单金额,也不作对账依据。实际应付金额以百度智能云控制台账单为准。 两者可能因折扣/优惠券/活动价、按日出账(
current_month为跨多张日账单的累计值)、出账与查询区间不完全对齐、少量用量在途未入账等原因存在差异。
评价此篇文章
