查询消费聚合记录

按 10 分钟窗口汇总计费用量的费用,并返回参与聚合的来源记录。

GET https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/transaction-aggregates

调用前准备

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

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

请求参数

将示例中的 $ACCOUNT_ID、$MOI_PERSONAL_ACCESS_TOKEN 替换为实际值。

curl -X GET \
  "https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/transaction-aggregates?page_size=2" \
  -H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN"

参数

类型

是否必填

说明

accountID

string

是

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

查询参数

参数

类型

是否必填

说明

from

string

否

按创建时间筛选的起点,包含该时刻。使用 RFC 3339 格式或有效的 YYYY-MM-DD 日期。传入 10 位 Unix 秒时间戳时返回 HTTP 400。省略时使用含当天在内的最近 30 天起点。

to

string

否

筛选终点,不包含该时刻。使用 RFC 3339 格式或有效的 YYYY-MM-DD 日期。传入日期时,以次日零点作为终点。不支持 10 位 Unix 秒时间戳。

timezone

string

否

IANA 时区。省略时使用账户地区的计费时区。

period

string

否

按入账账期筛选,格式为 YYYY-MM。

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。

成功响应

{
  "items": [
    {
      "aggregation_window_key": "window_example",
      "billing_account_id": "billing_account_example",
      "window_start": "2026-09-01T00:00:00+08:00",
      "window_end": "2026-09-01T00:10:00+08:00",
      "window_start_unix": 1788192000,
      "window_end_unix": 1788192600,
      "net_credit": "0.900000000000",
      "gross_credit": "1.000000000000",
      "discount_credit": "0.100000000000",
      "source_record_ids": [
        "rated_record_example"
      ],
      "source_record_count": 1,
      "meter_codes": [
        "meter_example"
      ],
      "workspace_ids": []
    }
  ],
  "total": 1,
  "next_page_token": ""
}

字段

类型

说明

items

array of object

本次返回的记录。

items[].aggregation_window_key

string

10 分钟聚合窗口标识。

items[].billing_account_id

string

计费账户 ID。

items[].window_start

string

窗口起点,RFC 3339 时间。

items[].window_end

string

窗口终点,不包含该时刻。

items[].window_start_unix

integer

窗口起点,Unix 秒。

items[].window_end_unix

integer

窗口终点,Unix 秒。

items[].net_credit

string

折扣后费用,单位为 Credit。

items[].gross_credit

string

折扣前费用,单位为 Credit。

items[].discount_credit

string

折扣抵扣,单位为 Credit。

items[].source_record_ids

array of string

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

items[].source_record_count

integer

参与聚合的记录数。

items[].meter_codes

array of string

窗口包含的计量项代码。

items[].workspace_ids

array of string

窗口包含的工作区 ID。

total

integer

符合筛选条件的总记录数。

next_page_token

string

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

curl -X GET \
  "https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/transaction-aggregates?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 相同。

最后更新于