Concept design — Quarry is not a real API. Designed by Coding Shields to show documentation where the reference is searchable and the examples are runnable.
Quarry v3
⌘K

Core resources / Queries

Run a query

Executes a query against a dataset and returns rows synchronously. Queries that exceed the synchronous limit return a job you poll instead — the same endpoint, a different shape, and the response tells you which one you got.

POST /v3/datasets/{dataset_id}/queries
import { Quarry } from '@quarry/node'

const quarry = new Quarry(process.env.QUARRY_KEY)

// Rows come back synchronously under ~15s of compute.
const result = await quarry.queries.run('ds_8c14', {
  select: ['region', 'sum(revenue) as revenue'],
  where:  { closed_at: { gte: '2026-01-01' } },
  group:  ['region'],
  limit:  500,
})

if (result.status === 'pending') {
  // Too large for a synchronous answer. Poll the job.
  await quarry.jobs.wait(result.job_id)
}

Parameters

FieldTypeDescription
select string[]
Required
Columns or aggregate expressions to return. Aliases with as are supported and become the key in each row.
where object
Optional
Filter tree. Operators are eq, ne, gt, gte, lt, lte, in and contains.
group string[]
Optional
Grouping columns. Every non-aggregate entry in select must appear here, or the request is rejected with 422.
limit integer
Optional
Maximum rows returned. Defaults to 1000, capped at 50000. Larger results should use an export.
cursor string
Optional
Opaque cursor from a previous response's next_cursor. Cursors expire after one hour.
Why some queries come back pending Anything projected to exceed fifteen seconds of compute is promoted to a job rather than held open on the connection. You cannot force the synchronous path — but you can make it more likely by narrowing the date range or raising the grouping level.

Response

A successful synchronous response carries status: "complete" and a rows array. A promoted query carries status: "pending" and a job_id, with no rows at all — check status before reading rows, not the other way round.

{
  "status": "complete",
  "row_count": 4,
  "next_cursor": null,
  "elapsed_ms": 318,
  "rows": [
    { "region": "emea",   "revenue": 4182900 },
    { "region": "amer",   "revenue": 6640155 },
    { "region": "apac",   "revenue": 2091044 },
    { "region": "latam",  "revenue": 877310 }
  ]
}

Errors

Every error carries a machine-readable code and a message written for a human reading a log at two in the morning. The message is safe to show to your own users; the detail field is not, because it can echo query fragments.

StatusCodeWhat went wrong
401invalid_keyThe key is malformed, revoked, or belongs to a different environment.
422ungrouped_columnA non-aggregate column in select is missing from group.
429rate_limitedOver the concurrency limit. Retry-After is always present on this response.
503dataset_rebuildingThe dataset is mid-rebuild. Reads resume automatically; this is never longer than ten minutes.