計
Usage API
2 operationsusage:read
Requests and billed units by day, route, API token or your own client reference, for up to 90 days at a time, plus a log of every call.
| GET | /usage | Sum requests and billed units over a time window, by day, route, client reference or API key. |
| GET | /usage/logs | List the account's API calls, newest first, by key, route or outcome. |
Sum requests and billed units over a time window, by day, route, client reference or API key.
GET
/v1/usagescope usage:read
Parameters
frominteger required | |
tointeger required | |
groupBystring | |
clientRefstring | |
tokenIdstring |
Response
4 fields
results | UsageBucket[] |
key | string |
requests | integer (int64) |
units | integer (int64) |
curl "https://api.hoshime.com/v1/usage?from=1&to=1" \ -H "Authorization: Bearer $HOSHIME_TOKEN"
const res = await fetch("https://api.hoshime.com/v1/usage?from=1&to=1", { headers: { Authorization: `Bearer ${process.env.HOSHIME_TOKEN}`, }, }); const { data, meta } = await res.json();
import os, requests res = requests.get( "https://api.hoshime.com/v1/usage?from=1&to=1", headers={"Authorization": f"Bearer {os.environ['HOSHIME_TOKEN']}"}, ) body = res.json()
{ "results": [ { "key": "…", "requests": 0, "units": 0 } ] }
List the account's API calls, newest first, by key, route or outcome.
GET
/v1/usage/logsscope usage:read
Parameters
tokenIdstring | |
routestring | |
statusstring | |
cursorstring | |
limitinteger |
Response
15 fields
hasMore | boolean |
nextCursor | string |
results | UsageEvent[] |
accountId | string |
clientRef | string |
createdAt | integer (int64) |
latencyMs | integer (int32) |
method | string |
requestId | string |
route | string |
scope | string |
statusCode | integer (int32) |
tokenId | string |
ttl | integer (int64) |
units | integer (int32) |
curl "https://api.hoshime.com/v1/usage/logs" \ -H "Authorization: Bearer $HOSHIME_TOKEN"
const res = await fetch("https://api.hoshime.com/v1/usage/logs", { headers: { Authorization: `Bearer ${process.env.HOSHIME_TOKEN}`, }, }); const { data, meta } = await res.json();
import os, requests res = requests.get( "https://api.hoshime.com/v1/usage/logs", headers={"Authorization": f"Bearer {os.environ['HOSHIME_TOKEN']}"}, ) body = res.json()
{ "hasMore": false, "nextCursor": "…", "results": [ { "accountId": "abc123", "clientRef": "…", "createdAt": 0, "latencyMs": 0, "method": "…", "requestId": "abc123", "route": "…", "scope": "…", "statusCode": 0, "tokenId": "abc123", "ttl": 0, "units": 0 } ] }