Get usage metrics
https://api.triport.io/v1/usage?range=24h&group=methodReturns aggregated request usage for the signed-in account over a time range, broken down by RPC method or by chain.
GET /v1/usage powers the usage dashboard in the Triport console. It returns
top-level totals (calls, errors, bytes) for the selected time range together
with a breakdown ("buckets") of the busiest dimensions — either by RPC method
or by chain.
This is a console endpoint, not a data-plane RPC method. It is authenticated with the browser session cookie established at sign-in, not with an API key, and it reports on usage accrued by all of your API keys in aggregate. There is no required API scope.
Responses are cached server-side for 60 seconds per (account, range, group)
combination. A served cache entry carries the header X-Cache: HIT; a freshly
computed response carries X-Cache: MISS. Because of this, two identical
requests made within the same minute return byte-identical bodies.
Parameters
All parameters are query-string parameters; there is no request body.
rangestringoptional1h, 24h, 7d, 30d. Defaults to 24h. Any other value returns invalid_range.groupstringoptionalbuckets array. One of method or chain. Defaults to method. Any other value returns invalid_group.Response
Response fields
| Field | Type | Description |
|---|---|---|
range | string | Echo of the effective range (the default 24h when omitted). |
group | string | Echo of the effective group (the default method when omitted). |
totals | object | Account-wide aggregate over the range. |
totals.calls | integer | Total number of calls. |
totals.errors | integer | Number of calls that returned an error. |
totals.bytes | integer | Total response bytes served. |
buckets | array | Top 20 rows by call volume for the chosen group. Empty array when there is no usage in the range. |
buckets[].bucket | string | The dimension value — an RPC method name when group=method, or a chain name when group=chain. |
buckets[].calls | integer | Calls attributed to this bucket. |
buckets[].errors | integer | Errored calls attributed to this bucket. |
buckets[].avg_ms | number | Average response latency for this bucket, in milliseconds. |
over_quota | boolean | true when the account's total calls exceed the included-call allowance of its active plan. false when within allowance or when no metered plan applies. |
Response headers
| Header | Description |
|---|---|
X-Cache | HIT when served from the 60-second server-side cache, MISS when freshly computed. |
Errors
| Code | HTTP | When it happens |
|---|---|---|
invalid_range | 400 | range is set to a value other than 1h, 24h, 7d, or 30d. |
invalid_group | 400 | group is set to a value other than method or chain. |
unauthenticated | 401 | No valid session cookie is present. |
method_not_allowed | 405 | Any HTTP method other than GET. |
See errors.md for the full error envelope.
Examples
JavaScript (fetch)
const res = await fetch(
"https://api.triport.io/v1/usage?range=7d&group=chain",
{ credentials: "include" } // sends the session cookie
);
const usage = await res.json();
console.log(`Calls (7d): ${usage.totals.calls}`);
for (const row of usage.buckets) {
console.log(`${row.bucket}: ${row.calls} calls, ${row.avg_ms} ms avg`);
}TypeScript SDK (@triport/sdk)
import { TriportConsole } from "@triport/sdk";
const console = new TriportConsole(); // uses the active browser session
const usage = await console.usage.get({ range: "30d", group: "method" });
if (usage.over_quota) {
console.warn("Account is over its included-call allowance");
}Python (triport-sdk)
from triport import ConsoleClient
console = ConsoleClient(session=TRIPORT_SESSION)
usage = console.usage(range="24h", group="chain")
print(f"Total calls: {usage.totals.calls}")
for row in usage.buckets:
print(f"{row.bucket}: {row.calls} calls, {row.avg_ms:.1f} ms avg")Notes
- The
bucketsarray is capped at the top 20 rows by call volume; lower-volume methods or chains are not returned individually and are not summed into a remainder row. Usetotalsfor the complete figure. totalsalways reflects the full range regardless of how many buckets are returned, sosum(buckets[].calls)can be less thantotals.calls.- Caching is keyed on
(account, range, group). Switching eitherrangeorgroupproduces a distinct cache entry, so the first request after a change is always anX-Cache: MISS. - This endpoint is account-scoped and aggregates across every API key. To see
the set of endpoints provisioned for a single key, use the per-key endpoint
catalogue under
/v1/keys/{id}/endpoints.