SQL

Run a read-only SQL query over the warehouse

Query the grants warehouse directly when the fixed endpoints can't express the question.

Accepts ONE read-only statement: SELECT or WITH ... SELECT. Multiple statements, any DDL/DML, and the file-reading functions (read_parquet, read_csv, …) are rejected — you query named views, not files. The view list, every column, and the caveats that decide whether an answer is right are documented at https://data.useplinth.com/developers/schema.

grants is the US corpus in US dollars; Canadian T3010 filings are a separate view, grants_ca, in Canadian dollars. Neither is a filter on the other, because a total spanning both adds CAD to USD.

Two ceilings, and they bound different things. Results are capped at 2,000 rows (truncated: true says you hit it) — aggregate in SQL rather than paging. Separately, a query is cancelled after 30 seconds: the row cap limits the response, this limits the scan behind it. A cancelled query returns 400, so narrow it with a tax_year or funder_ein filter and retry.

Every response carries x_plinth.datasets: the licence and required attribution for each corpus you can reach here. Which one answered is not knowable per query, so all of them are listed. The Canadian attribution is a condition of the licence — reproduce it wherever you publish figures drawn from it.

Requires a paid key — there is no free SQL tier — and costs one call from your monthly allowance, the same as any other endpoint. Asset-intelligence and governance tables additionally need Pro.

post/api/v1/sql

Request

  • Base URL: https://data.useplinth.com
  • URL: https://data.useplinth.com/api/v1/sql
  • Auth: API key in header X-API-Key

Request body

sqlstring required

A single read-only SELECT (or WITH ... SELECT) statement.

Example request

{
  "sql": "SELECT funder_ein, sum(amount) AS total, count(*) AS n FROM grants WHERE tax_year = 2023 GROUP BY 1 ORDER BY total DESC LIMIT 10"
}

Response

The rows the query returned.

codeinteger
messagestring required
rowsobject[] required
row_countinteger required
truncatedboolean required

Changes

No recorded changes to this operation across all 1 revision of this API.