余额查询 API
查询当前 API Key 对应的普通账户余额或企业项目预算使用情况,系统根据 API Key 类型自动返回对应的数据结构。新老网关均支持,无需请求参数。
BASE URL
https://router.shengsuanyun.com/api/v1认证方式
Authorization: Bearer YOUR_API_KEY端点列表
响应字段说明 · 普通网关(gateway_type=common)
{
"success": true,
"data": {
"gateway_type": "common",
"account_balance_cny": 12.5,
"voucher_balance_cny": 2.5,
"gateway_voucher_balance_cny": 3.7,
"cash_balance_cny": 10,
"credit_limit_cny": 8,
"locked_balance_cny": 1.5
}
}| 字段 | 类型 | 说明 |
|---|---|---|
success | boolean | 查询是否成功 |
gateway_type | string | 网关类型,common 表示普通网关 |
account_balance_cny | number | 账户总余额,不包含业务专属代金券和授信额度 |
voucher_balance_cny | number | 通用代金券余额 |
gateway_voucher_balance_cny | number | Gateway 专属代金券余额 |
cash_balance_cny | number | 充值形成的人民币余额 |
credit_limit_cny | number | 当前有效授信额度 |
locked_balance_cny | number | 尚未最终扣除的待扣或预扣金额 |
所有金额字段的单位均为人民币元。
响应字段说明 · 企业网关(gateway_type=enterprise)
{
"success": true,
"data": {
"gateway_type": "enterprise",
"scope": "account_in_project",
"project_id": 65,
"ram_user_id": 222,
"budget_kind": "monthly",
"period_kind": "monthly",
"period_start": "2026-09-01T00:00:00+08:00",
"period_end": "2026-10-01T00:00:00+08:00",
"period_consumed_cny": 47.548226,
"period_limit_cny": 1000,
"remaining_percentage": 95.25,
"unlimited": false
}
}| 字段 | 类型 | 说明 |
|---|---|---|
success | boolean | 查询是否成功 |
gateway_type | string | 网关类型,enterprise 表示企业网关 |
scope | string | 统计范围,account_in_project 表示当前账号在当前项目中的消费 |
project_id | integer | 企业网关项目 ID |
ram_user_id | integer | RAM 用户 ID,0 表示主账号 |
budget_kind | string | 预算类型:daily、monthly 或 unlimited |
period_kind | string | 当前统计周期:daily 或 monthly |
period_start | string | 统计周期开始时间,使用北京时间 |
period_end | string | 统计周期结束时间,使用北京时间 |
period_consumed_cny | number | 当前周期已消费金额,单位为人民币元 |
period_limit_cny | number/null | 当前周期预算限额,单位为人民币元;不限额时为 null |
remaining_percentage | number/null | 剩余预算百分比;不限额时为 null |
unlimited | boolean | 是否不限额,true 表示没有金额预算限制 |
企业网关消费按当前账号、项目和预算周期统计,不包含 BYOK 消费。
GET/balance查询 API Key 余额
查询当前 API Key 对应的普通账户余额或企业项目预算使用情况。系统会根据 API Key 类型自动返回对应的数据结构,无需任何请求参数和请求体。响应字段说明见下方「响应字段说明」板块。
请求示例
参考地址:https://router.shengsuanyun.com/api/v1。路径参数与凭据需替换;非 JSON 请求体需按对应格式准备。
curl -X GET 'https://router.shengsuanyun.com/api/v1/balance' \
-H 'Authorization: Bearer YOUR_API_KEY'响应
200 查询成功。普通网关返回账户余额结构(gateway_type=common);企业网关返回项目预算结构(gateway_type=enterprise)。两种结构的完整字段说明见下方「响应字段说明」板块。
application/json
未提供结构定义。
{
"success": true,
"data": {
"gateway_type": "common",
"account_balance_cny": 12.5,
"voucher_balance_cny": 2.5,
"gateway_voucher_balance_cny": 3.7,
"cash_balance_cny": 10,
"credit_limit_cny": 8,
"locked_balance_cny": 1.5
}
}401 认证失败:API Key 无效、过期或缺失
application/json
未提供结构定义。
{
"error": {
"message": "Token已失效",
"type": "authentication_error",
"code": "invalid_api_key"
}
}500 服务器错误:余额或消费数据查询失败
application/json
未提供结构定义。
{
"success": false,
"data": null,
"msg": "查询余额或消费失败"
}