query

Execute a read-only SQL query

Runs a SELECT / WITH / EXPLAIN against the target connection. Read-only enforcement runs at three layers (sql-guard, session READ ONLY, optional per-connection firewall) below this handler — writes are rejected with code: SYNTAX or PERMISSION_DENIED and never reach the upstream DB. Costs 1 quota unit per successful call.

post/v1/query

Request

  • Base URL: https://data.thinair.co
  • URL: https://data.thinair.co/v1/query
  • Auth: API key in header x-api-key

Request body

querystring required

Read-only SQL statement (SELECT / WITH / EXPLAIN only). Multiple statements not allowed; sql-guard runs additional checks before execution.

connectionstring

Connection name or id from this tenant's inventory. Falls back to the tenant's default (first added) when omitted. Mirrors the MCP query_sql tool's connection arg.

limitinteger

Max rows to return (default 100, max 1000). Mirrors query_sql.limit.

Example request

{
  "query": "SELECT id, status FROM vehicles LIMIT 10",
  "connection": "fleet",
  "limit": 100
}

Response

Query result.

rowsobject[] required

Result rows. Each row is a {column: value} map. null is used for SQL NULL; numbers, booleans, strings, arrays, and JSON objects flow through as their JS shape.

columnsstring[] required

Column names from the first row's keys (or [] when rows is empty). Service-layer executeQuery returns row dicts without a separate column list; deriving from the first row matches the MCP envelope's behavior.

Changes

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