查询交易流水

分页查询账户的充值、消费、赠送和退款交易。

GET https://billing.moi.matrixorigin.cn/api/v1/billing/accounts/$ACCOUNT_ID/transactions

调用前准备

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

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

请求参数

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

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

to

string

否

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

timezone

string

否

解析日期值的 IANA 时区。省略时使用 UTC。

direction

string

否

收入使用 income,支出使用 expense。

transaction_type

string

否

按来源类型筛选:recharge、grant、consume、refund、reservation。也接受对应来源类型代码。

channel

string

否

按支付渠道或赠送来源渠道筛选。

status

string

否

按来源订单、赠送审批或计费用量记录的状态筛选。

q

string

否

搜索账务交易 ID、来源 ID、支付订单号、支付渠道交易号或赠送原因,不区分大小写。

search

string

否

q 的别名。仅在 q 为空时生效。

page_size

integer

否

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

page_token

string

否

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

成功响应

{
  "items": [
    {
      "transaction_id": "transaction_example",
      "ledger_txn_id": "ledger_example",
      "billing_account_id": "billing_account_example",
      "billing_account_owner_id": "owner_example",
      "billing_account_display_name": "Example account",
      "created_at": 1788739200,
      "entry_type": "consume",
      "source_type": "rated_usage_record",
      "source_id": "rated_record_example",
      "description": "Example usage",
      "amount": "0.900000000000",
      "balance_delta": "-0.900000000000",
      "currency": "CREDIT",
      "after_balance": "99.100000000000",
      "detail_available": true
    }
  ],
  "total": 1,
  "next_page_token": ""
}

字段

类型

说明

items

array of object

本次返回的记录。

items[].transaction_id

string

交易记录 ID。

items[].ledger_txn_id

string

账务交易 ID。

items[].billing_account_id

string

计费账户 ID。

items[].billing_account_owner_id

string

账户所属主体的 ID,可能省略。

items[].billing_account_display_name

string

账户显示名称,可能省略。

items[].created_at

integer

创建时间,Unix 秒。

items[].entry_type

string

账务分录类型。

items[].source_type

string

交易来源类型。

items[].source_id

string

交易来源对象 ID。

items[].source_channel

string

交易来源渠道,存在时返回。

items[].description

string

交易说明。

items[].amount

string

交易金额的十进制字符串,单位由 currency 指定。

items[].balance_delta

string

余额变化量,收入为正,支出为负。

items[].currency

string

交易单位。Credit 交易返回 CREDIT。

items[].after_balance

string

账务分录记录的变更后余额。

items[].related_order_no

string

关联充值订单号,存在时返回。

items[].detail_available

boolean

是否有可用的交易来源明细。

total

integer

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

next_page_token

string

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

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

最后更新于