查询月账单用量明细

按入账账期对计费用量分组,返回账单用量明细。

GET https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/monthly-bills/$PERIOD/line-items

调用前准备

  1. 准备计费账户所属用户的有效个人访问令牌

  2. 调用查询当前账户接口,获取目标账户的 ID。

  3. 调用查询计费用量记录接口,获取目标账户已有用量的入账账期。

请求示例

将示例中的 $MOI_PERSONAL_ACCESS_TOKEN$ACCOUNT_ID$PERIOD 分别替换为个人访问令牌、账户 ID 和入账账期。

curl -X GET \
  "https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/monthly-bills/$PERIOD/line-items?dimension=meter&page_size=2" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"

路径参数

参数

类型

是否必填

说明

accountID

string

目标账户的 ID,取自“查询当前账户”响应中的 items[].billing_account_id

period

string

目标账户的入账账期,取自“查询计费用量记录”响应中的 items[].posting_period,格式为 YYYY-MM

查询参数

参数

类型

是否必填

说明

dimension

string

聚合维度:meter、workspace、service、day,默认 meter。day 按 UTC 日期分组。

meter_code

string

按计量项代码筛选。

billing_item_code

string

按计费项代码筛选;与 meter_code 同时提供时须匹配同一计量项。

workspace_id

string

按用量事件所属工作区筛选。

status

string

按用量记录状态筛选;查询已扣费记录时使用 charged。省略时不按状态筛选。

subject_type

string

按账户归属主体类型筛选。

subject_id

string

按账户归属主体 ID 筛选。

q

string

搜索计费用量记录 ID、用量事件 ID、计量项代码或事件键,不区分大小写。

search

string

q 的兼容参数,仅在 q 为空时使用。

page_size

integer

每页数量,1–100;省略、非正数或大于 100 时使用 50。

page_token

string

下一页标记。首次请求省略;后续使用响应的 next_page_token

成功响应

请求成功时返回 HTTP 200 和聚合后的用量明细。

{
  "items": [
    {
      "line_item_id": "billline:2026-09:meter:meter_example",
      "period": "2026-09",
      "line_type": "usage",
      "dimension": "meter",
      "group_key": "meter_example",
      "group_label": "Example usage",
      "meter_code": "meter_example",
      "billing_item_code": "meter_example",
      "billing_item_display_name": "Example usage",
      "unit": "token",
      "quantity": "1000",
      "gross_credit": "1.000000000000",
      "discount_credit": "0.100000000000",
      "net_credit": "0.900000000000",
      "credit_amount": "0.900000000000",
      "source_record_ids": [
        "rated_record_example"
      ],
      "source_record_count": 1
    }
  ],
  "total": 1,
  "next_page_token": ""
}

字段

类型

说明

items

array of object

聚合后的用量明细行。

items[].line_item_id

string

账单用量明细行 ID。

items[].period

string

入账账期,格式为 YYYY-MM

items[].line_type

string

明细类型,返回 usage。

items[].dimension

string

使用的聚合维度。

items[].group_key

string

分组标识。

items[].group_label

string

分组显示名称。

items[].meter_code

string

计量项代码。

items[].billing_item_code

string

计费项代码。

items[].billing_item_display_name

string

计费项显示名称。

items[].unit

string

明细行的计量单位;跨计量项聚合时,取该组首条记录的单位。

items[].workspace_id

string

按工作区聚合时返回,可能省略。

items[].service_code

string

按服务聚合时返回,可能省略。

items[].bucket_start

string

按天聚合时的 UTC 日期起点,可能省略。

items[].bucket_end

string

按天聚合时的 UTC 日期终点,可能省略。

items[].quantity

string

分组内的用量合计。

items[].gross_credit

string

折扣前费用,单位为 Credit。

items[].discount_credit

string

折扣抵扣,单位为 Credit。

items[].net_credit

string

折扣后费用,单位为 Credit。

items[].credit_amount

string

明细行费用,与 net_credit 相同,单位为 Credit。

items[].source_record_ids

array of string

参与聚合的计费用量记录 ID。

items[].source_record_count

integer

参与聚合的记录数。

total

integer

符合条件的聚合明细行总数。

next_page_token

string

下一页标记,空字符串表示没有下一页。

字段路径中的 [] 表示数组中的每一项。例如,items[].line_item_id 表示数组中每一项的对应字段。

将响应中的 next_page_token 保存为 $NEXT_PAGE_TOKEN,保持筛选条件不变继续查询。标记为空时停止翻页。

curl -X GET \
  "https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/monthly-bills/$PERIOD/line-items?dimension=meter&page_size=2&page_token=$NEXT_PAGE_TOKEN" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"

错误响应

缺少认证信息时返回 HTTP 401,请提供有效的个人访问令牌。

{
  "code": "unauthenticated",
  "message": "missing bearer token",
  "error": "missing bearer token"
}

字段

类型

说明

code

string

错误代码。

message

string

错误说明。

error

string

兼容错误说明,与 message 内容相同。

最后更新于