§ API REFERENCE

查询用量记录

GET/usage-recordsscope: usage:read

按时间、状态和产品查询当前 APP 的执行、结算与报告摘要,使用 keyset cursor 分页。

鉴权:Authorization: Bearer <access_token>。查询参数:created_from、created_to、status、resource_type、external_user_id、limit、cursor。
§ 1

请求信息

GET https://api.lingxiguangnian.com/api/open/v1/usage-records

请求头

参数类型必填说明
AuthorizationstringBearer <access_token>。由 POST /token 换取,有效期 2 小时;api_secret 不得直连业务端点(→ 401)。
§ 2

调用示例

curl "https://api.lingxiguangnian.com/api/open/v1/usage-records?limit=20" -H "Authorization: Bearer oat_xxxxxxxxxxxxxxxx"
§ 3

返回结果

返回字段

参数类型必填说明
records[]object[]execution_id、状态、资源、去PII主体、credit_amount、settlement_status、报告状态与时间。
next_cursorstring | null下一页不透明游标;null 表示结束。
{
  "success": true,
  "data": {
    "records": [{ "execution_id": "9b8e0c2a-3d4f-4a5b-8c6d-7e8f9a0b1c2d", "settlement_status": "SETTLED", "credit_amount": 5, "report_status": "READY" }],
    "next_cursor": null
  }
}
§ 4

端点错误码

通用鉴权、scope 与限流错误见「使用概述」;下表为本端点专属错误。

HTTPerror_code触发条件
422open_api.invalid_cursorcursor 无效或被篡改。
500open_api.usage_query_failed用量派生查询失败。

契约真源:apps/m-master/src/app/api/open/v1/usage-records/route.ts