应用维用量(console 用量页应用统计):data = 本 owner 全部未删应用(api_keys scopes 含 app;零用量在列全零,status active|disabled,按请求数降序);other =「非应用」桶(api_key_id NULL 的 JWT/CLI 登录态直连 + PAT 键归因 + 已删应用遗留数值归档,三类合并单列);归因 = usage_events.api_key_id(/t1 数据面 app 键恒填);?window=Nd 沿 /v1/usage(缺省 7d,1..90 钳制);usage 形 = {requests,inTokens,outTokens,cacheRTokens,cacheWTokens,cost,listCost,discount,byCurrency[]},cost/listCost/discount 恒 CNY 锚、byCurrency 分币分桶(每桶同携三列)恒不跨币加总;协议价三列:listCost 牌价 / cost 实收 / discount = listCost − cost,牌价客户 listCost ≡ cost、discount 0;带 x-tansr-org 头 = org 应用视图,观察面 owner/admin/billing
GET
/v1/usage/by-app
const url = 'https://api.tansr.com/v1/usage/by-app';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.tansr.com/v1/usage/by-app \ --header 'Authorization: Bearer <token>'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”x-tansr-org
string
Org 作用域声明(org 公开 id);服务端校验成员资格与角色,非成员恒 404、角色不够 403
Responses
Section titled “Responses”应用用量({window, data[], other})
Media typeapplication/json
object
key
additional properties
any
Examplegenerated
{}Bad_request(window 形状)
Media typeapplication/json
object
error
required
object
code
required
错误码注册表单源派生(src/http/errors.ts ERROR_CODES;码稳定,消费方按码翻译)
string
message
required
string
requestId
required
string
detail
object
Example
{ "error": { "code": "adjudicator_not_authorized" }}本文是否有帮助?
感谢反馈,我们会持续改进这篇文章。