API
The Token Usage Dashboard interface fetches all its data through a JSON API. You can query it yourself too, for example with curl, as long as the server is running. For example, this is how you query the metrics for September 2026:
curl "http://127.0.0.1:8000/api/metrics?from=2026-09-01&to=2026-09-30"
JSON API endpoints
The following table lists the endpoints of the Token Usage Dashboard JSON API with their contents and supported parameters:
| Endpoint | Contents | reload | from/to | models |
|---|---|---|---|---|
GET /api/data | raw data, file list, models, months, period, check result, runtime | yes | – | – |
GET /api/metrics | all metrics of the overview | yes | yes | yes |
GET /api/health | only the check result with the export status | yes | – | – |
GET /api/projects | metrics per project | yes | yes | yes |
GET /api/sessions | metrics per session, sorted and paged | yes | yes | yes |
GET /api/blocks | metrics of the 5-hour blocks | yes | yes | – |
GET /api/rtk | metrics of the RTK savings | yes | yes | – |
GET /LICENSE | license text of the AGPL-3.0 | – | – | – |
JSON API parameters
The Token Usage Dashboard JSON API accepts these general parameters:
reload=1reads all files again, like the Reload data button.fromandtolimit the period, as a dateYYYY-MM-DD.modelsselects models. The parameter may occur several times and hold lists:?models=a,b&models=c.
/api/blocks and /api/rtk ignore models. The block source reports no per-model cost split, and the RTK source knows nothing about models. Both responses therefore carry modelFilterSupported: false.
Extra parameters for /api/sessions
The following table lists the extra parameters of the /api/sessions endpoint with their values and defaults:
| Parameter | Values | Default |
|---|---|---|
project | exact project key, empty means all | empty |
sort | start, duration, project, cost, tokens | cost |
dir | asc, desc | desc |
page | positive integer | 1 |
A page holds 50 sessions. A page beyond the last is clamped to the last one; the actual number is in page.number. An unknown project is not an error but a valid filter without matches.
JSON API responses and errors
All responses of the Token Usage Dashboard JSON API are JSON with Cache-Control: no-store. Timestamps appear as ISO-8601 in UTC; only the interface converts them to local time.
Messages and errors never come as a finished sentence, but as a key with parameters, for example:
{ "code": "http.param_invalid", "params": { "name": "sort", "value": "price" } }
The server knows no language; only the browser builds the text in the selected language.
The following table lists the error keys of the JSON API and their meaning:
| Key | Meaning |
|---|---|
http.path_unknown | unknown path |
http.param_invalid | invalid value for sort, dir or page (HTTP 400) |
http.file_missing | file missing |
http.data_directory | problem with the data directory |
http.internal_error | internal error |
HEAD is treated like GET.