Returns the authenticated developer's most-called API endpoints ranked by call volume within a requested time window. Useful for identifying hot endpoints, spotting usage spikes, and optimising spend.
GET /api/usage/by-endpoint
Authorization: Bearer <token>
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
from |
string | No | 30 days ago | Start of period (ISO-8601, e.g. 2026-06-01T00:00:00Z) |
to |
string | No | Now | End of period (ISO-8601) |
limit |
integer | No | 5 |
Maximum number of endpoints to return (≥ 1) |
apiId |
string | No | all APIs | Filter results to a specific registered API |
- If
fromandtoare both omitted the last 30 days are used. frommust be ≤to; otherwise a400is returned.limitmust be a positive integer; otherwise a400is returned.
HTTP 200:
{
"data": [
{ "endpoint": "/v1/weather/current", "calls": 142, "revenue": "142000" },
{ "endpoint": "/v1/weather/forecast", "calls": 87, "revenue": "87000" }
],
"period": {
"from": "2026-06-01T00:00:00.000Z",
"to": "2026-07-01T00:00:00.000Z"
}
}| Field | Type | Description |
|---|---|---|
data |
array | Endpoints ordered by calls descending; ties broken by path ascending. |
data[].endpoint |
string | Endpoint path identifier (e.g. /v1/weather/current). |
data[].calls |
integer | Total call count in the period. |
data[].revenue |
string | Total revenue in smallest USDC units (string to avoid precision loss). |
period.from |
string | Effective start of the query window (ISO-8601). |
period.to |
string | Effective end of the query window (ISO-8601). |
| HTTP status | Code | When |
|---|---|---|
400 |
BAD_REQUEST |
Invalid date, from > to, or invalid limit. |
401 |
UNAUTHORIZED |
Missing or invalid bearer token. |
500 |
INTERNAL_ERROR |
Unexpected server error. |
See docs/error-codes.md for the full error envelope format.
Requires a valid developer bearer token (Authorization: Bearer <token>) or x-user-id header in local/test flows. Results are always scoped to the authenticated developer — cross-developer data is never returned.
- In-memory store (
InMemoryUsageEventsRepository): groups events byendpoint, sums calls and revenue, then sorts by calls descending (ties broken by path ascending) before slicing tolimit. - PostgreSQL store (
PgUsageEventsRepository): issues a singleGROUP BY endpoint_id ORDER BY calls DESCquery with a parameterisedLIMIT, running entirely within the database for efficiency. - The route is mounted at
/api/usage/by-endpointbefore the generic/api/usagemount so the more-specific path always matches first. - The standard REST rate limiter applies to this route (configurable via
REST_RATE_LIMIT_WINDOW_MS/REST_RATE_LIMIT_MAX_REQUESTS).
curl -s \
-H "Authorization: Bearer $TOKEN" \
"https://api.callora.io/api/usage/by-endpoint?limit=3&from=$(date -u -d '-7 days' +%Y-%m-%dT%H:%M:%SZ)"curl -s \
-H "Authorization: Bearer $TOKEN" \
"https://api.callora.io/api/usage/by-endpoint?apiId=api_abc123&limit=10"