§ 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
请求信息
REQUESTGET https://api.lingxiguangnian.com/api/open/v1/usage-records请求头
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string | 是 | Bearer <access_token>。由 POST /token 换取,有效期 2 小时;api_secret 不得直连业务端点(→ 401)。 |
§ 2
调用示例
EXAMPLESGET /usage-records
curl "https://api.lingxiguangnian.com/api/open/v1/usage-records?limit=20" -H "Authorization: Bearer oat_xxxxxxxxxxxxxxxx"
§ 3
返回结果
RESPONSE返回字段
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
records[] | object[] | 是 | execution_id、状态、资源、去PII主体、credit_amount、settlement_status、报告状态与时间。 |
next_cursor | string | null | 是 | 下一页不透明游标;null 表示结束。 |
RESPONSE · JSON
{
"success": true,
"data": {
"records": [{ "execution_id": "9b8e0c2a-3d4f-4a5b-8c6d-7e8f9a0b1c2d", "settlement_status": "SETTLED", "credit_amount": 5, "report_status": "READY" }],
"next_cursor": null
}
}§ 4
端点错误码
ERRORS通用鉴权、scope 与限流错误见「使用概述」;下表为本端点专属错误。
| HTTP | error_code | 触发条件 |
|---|---|---|
| 422 | open_api.invalid_cursor | cursor 无效或被篡改。 |
| 500 | open_api.usage_query_failed | 用量派生查询失败。 |
契约真源:apps/m-master/src/app/api/open/v1/usage-records/route.ts