/exec endpoint executes SQL queries and returns results as JSON.
Endpoint
Query Parameters
SQL query to execute. Must be URL-encoded.
Limit the number of rows returned. Format:
limit or skip,limit.Examples:limit=100- return first 100 rowslimit=50,100- skip 50 rows, return next 100
http.json.query.max.response.rows (default: 10,000).When
true, only count rows without returning data. Response includes count field.When
true, exclude column metadata from response (no meta).When
true, include query execution timings in response.When
true, return query execution plan instead of results.When
true, quote large numbers (LONG256) as strings to prevent precision loss in JSON.Comma-separated list of column names to return. Returns only specified columns.Example:
cols=timestamp,sensor_id,temperatureRequest Headers
Query timeout in milliseconds. Query is cancelled if it exceeds this duration.Example:
30000 (30 seconds)HTTP Basic authentication credentials (if authentication is enabled).Format:
Basic base64(username:password)Response
The executed SQL query.
Array of column metadata objects (omitted if
nm=true).Array of row arrays containing query results. Each row is an array of values matching the column order.
Number of rows returned (or total count if
count=true).Query execution timings in milliseconds (only if
timings=true).Query execution plan (only if
explain=true).Error Response
The attempted SQL query.
Error message describing what went wrong.
Character position in the query where the error occurred.
Examples
Basic SELECT Query
Query with Pagination
Skip the first 100 rows and return the next 50:Count Only
Get row count without fetching data:Query with Timings
INSERT Statement
CREATE TABLE
Query with Timeout
Select Specific Columns
Error Examples
Syntax Error
Table Not Found
Query Timeout
Supported SQL Operations
The/exec endpoint supports all SQL operations:
- SELECT - Query data
- INSERT - Insert rows
- UPDATE - Update rows (with conditions)
- CREATE TABLE - Create new tables
- ALTER TABLE - Modify table structure
- DROP - Drop tables or columns
- TRUNCATE - Remove all rows from a table
- COPY - Not supported over REST (use PostgreSQL wire protocol)
Data Types
Column types in the response:| Type | JSON Representation | Example |
|---|---|---|
BOOLEAN | boolean | true |
BYTE | number | 127 |
SHORT | number | 32767 |
INT | number | 2147483647 |
LONG | number | 9223372036854775807 |
FLOAT | number | 3.14 |
DOUBLE | number | 3.141592653589793 |
STRING | string | "hello" |
SYMBOL | string | "BTCUSD" |
TIMESTAMP | string (ISO 8601) | "2024-01-01T00:00:00.000000Z" |
DATE | string (ISO 8601) | "2024-01-01" |
UUID | string | "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11" |
LONG256 | string (hex) | "0x123abc..." |
GEOHASH | string | "sp052w" |
BINARY | null | null |
Best Practices
The query cache improves performance for repeated queries. Queries with sensitive information (e.g., passwords) are not cached.