🔍

Run Saved Query

Execute a previously saved query definition against its bound or a specified dataset.

POST /v1/query/{query_id}
curl -X POST "https://analytics.toolkitapi.io/v1/query/qry_xyz789" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": "dset_abc123",
    "parameters": {
      "month": "2024-05"
    }
  }'
import httpx

resp = httpx.post(
    "https://analytics.toolkitapi.io/v1/query/qry_xyz789",
    json={
    "dataset_id": "dset_abc123",
    "parameters": {
      "month": "2024-05"
    }
  },
)
print(resp.json())
const resp = await fetch("https://analytics.toolkitapi.io/v1/query/qry_xyz789", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "dataset_id": "dset_abc123",
    "parameters": {
      "month": "2024-05"
    }
  }),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "query_id": "qry_xyz789",
  "dataset_id": "dset_abc123",
  "execution_mode": "sync",
  "status": "succeeded",
  "results": {
    "columns": ["region", "total_revenue"],
    "rows": [
      ["North", 48320.50],
      ["South", 31205.00],
      ["East", 27890.75],
      ["West", 19450.25]
    ],
    "row_count": 4
  },
  "job_id": null,
  "created_at": "2024-06-01T14:22:10Z"
}

Description

Execute a previously saved query definition against its bound or a specified dataset.

How to Use

1

1. Save a query with `POST /v1/save` and note the returned `query_id`. 2. Call `POST /v1/query/{query_id}` with the `dataset_id` you want to run it against. 3. For large datasets, set `"execution_mode": "async"` — you will receive a `job_id` in the response. 4. Poll `GET /v1/jobs/{job_id}` until `status` is `"succeeded"` or `"failed"`. 5. Parse the `results.rows` array for downstream use.

About This Tool

The Run Saved Query endpoint executes a query definition that was previously stored via `POST /v1/save`. It supports both synchronous and asynchronous execution modes, making it suitable for quick lookups as well as long-running aggregations over large datasets.

When running synchronously, results are returned inline in the response. For async execution, a `job_id` is returned and you poll `GET /v1/jobs/{job_id}` for completion.

Why Use This Tool

Start using Run Saved Query now

Get your free API key and make your first request in under a minute.