Queries API
Compile and run semantic-model queries, batch several at once, and inspect the compiled SQL — all under /api/query.
The queries endpoints compile a semantic-model query to dialect-correct SQL, run it
in your warehouse, and return rows. They require the read scope.
#Run a query
POST /api/query — compile and run one query.
curl https://flax-analytics.com/api/query \
-H "Authorization: Bearer flax_pat_..." \
-H "Content-Type: application/json" \
-d '{
"model": "orders",
"dimensions": ["orders.status"],
"measures": ["orders.revenue"],
"filters": [{ "field": "orders.created_at", "op": ">=", "value": "2026-01-01" }],
"orderBy": ["orders.revenue desc"],
"limit": 100
}'The response contains typed columns and rows:
{
"columns": [
{ "name": "orders.status", "type": "string" },
{ "name": "orders.revenue", "type": "number" }
],
"rows": [["completed", 128400.5], ["pending", 9120.0]]
}#Run several queries
POST /api/query/batch — run multiple queries in one round-trip. The response
returns one result per query, in request order. Prefer this over many single calls.
#Inspect a compiled query
POST /api/query/detail — return the compiled SQL and dialect for a query
without running it. Useful for debugging the semantic layer.
{ "sql": "SELECT status, SUM(amount) ...", "dialect": "snowflake" }