api reference

Query results

Fetch a query result by id, or download it as CSV/TSV/XLSX/JSON.

GET/api/query_results/{id}

Fetch a stored result by id. Access-checked against the result's data source, not the query that produced it — a result id alone is enough once the caller can view that data source.

Response

{
  "query_result": {
    "id": 501,
    "data_source_id": 3,
    "query": "select count(*) from signups",
    "query_hash": "a1b2c3",
    "data": { "columns": [{ "name": "count", "type": "integer" }], "rows": [{ "count": 42 }] },
    "runtime": 0.42,
    "retrieved_at": "2026-07-17T12:00:00Z"
  }
}

GET/api/query_results/{id}.{format}

Same result, streamed as a file download instead of JSON. format is one of csv, tsv, xlsx, or json; an unsupported extension is a 400.

POST/api/query_results

Ad-hoc execute: run SQL that isn't (yet) a saved query. Same cache-or-enqueue outcome as the queries resource's refresh/run endpoints — see the async query model. Optionally tag the run against an existing query_id, and/or pass a max_age (seconds) to force a fresh run instead of serving a cached result.

Request

{
  "data_source_id": 3,
  "query": "select count(*) from signups where created_at > {{ since }}",
  "parameters": { "since": "2026-07-01" },
  "max_age": 0
}

Response

// EITHER an immediate result: { "query_result": { "...": "..." } }
// OR an enqueued job:        { "job": { "id": "9001", "status": 1, "query_result_id": null } }