Skip to main content

API Documentation

Modifiers​

POST /build_source_table​

takes your schema and builds the source table​

request body

{
"log_id_column": "log_id",
"partition_id": { "column_name": "sensor_id", "data_type": "TEXT" },
"value_columns": [
{ "column_name": "temperature", "data_type": "REAL" },
{ "column_name": "humidity", "data_type": "REAL" },
{ "column_name": "pressure", "data_type": "REAL" }
],
"additional_columns": [
{ "column_name": "timestamp", "data_type": "INTEGER" }
]
}

KeyDescriptionAllowed Types
log_id_columnName of column that holds log IDINTEGER
partition_idName and type of partition columnINTEGER, TEXT
value_columnsName and type of aggregation columnsINTEGER, REAL
additional_columnsOptional extra columnsINTEGER, REAL, TEXT

POST /modify_source_table​

provides mechanism to insert, update, or delete on the source table​

request body

{
"sql_strings": [
"INSERT INTO source (log_id, sensor_id, temperature, humidity, pressure, timestamp) VALUES (101, 'sensor_a', 21.4, 48.0, 1013.2, 1791566400)",
"UPDATE source SET temperature = 21.9 WHERE log_id = 42",
"DELETE FROM source WHERE log_id = 17"
]
}
KeyDescriptionAllowed SQL Commands
sql_stringsList of SQL statementsINSERT, UPDATE, DELETE

POST /delete_source_table​

deletes the source table​

response body

{ "status": "pipeline deleted" }

POST /set_recovery_mode​

Toggles recovery mode. While on, readers are blocked and writes are allowed​

request body

{ "recovery_mode": true }

KeyDescriptionAllowed Values
recovery_modeTurns recovery mode on or offtrue, false

Readers​

POST /query_all​

runs aggregations over every row in a partition​

request body

{
"partitions": ["sensor_a"],
"aggregations": [
{ "function": "FAVG", "columns": ["temperature"] },
{ "function": "MAX", "columns": ["pressure"] }
]
}

KeyDescriptionAllowed Values
partitionsPartition IDs to queryUp to 10
aggregationsFunction and columns for each aggregationUp to 10
filtersOptional row filters=, !=, >, >=, <, <=, BETWEEN, IN, LIKE, IS, IS NULL, IS NOT NULL
response body

{
"sensor_a": {
"all": {
"favg_temperature": 21.6,
"max_pressure": 1015.8
}
}
}

POST /query_inner​

First filter. Then aggregates the last (or first) n matches​

request body

{
"partitions": ["sensor_a"],
"last_n": 100,
"filters": [
{ "column": "temperature", "operator": ">", "value": 20 }
],
"aggregations": [
{ "function": "FAVG", "columns": ["temperature"] },
{ "function": "MAX", "columns": ["pressure"] }
]
}

KeyDescriptionAllowed Values
partitionsPartition IDs to queryUp to 10
first_nNumber of oldest matching rowsPositive integer, or use last_n
last_nNumber of newest matching rowsPositive integer, or use first_n
aggregationsFunction and columns for each aggregationUp to 10
filtersOptional row filters=, !=, >, >=, <, <=, BETWEEN, IN, LIKE, IS, IS NULL, IS NOT NULL
response body

{
"sensor_a": {
"last_n": {
"favg_temperature": 22.7,
"max_pressure": 1015.1
}
}
}

POST /query_outer​

First select the last (or first) n rows. Then aggregates only on filter matches​

request body

{
"partitions": ["sensor_a"],
"last_n": 100,
"filters": [
{ "column": "temperature", "operator": ">", "value": 20 }
],
"aggregations": [
{ "function": "FAVG", "columns": ["temperature"] },
{ "function": "MAX", "columns": ["pressure"] }
]
}

KeyDescriptionAllowed Values
partitionsPartition IDs to queryUp to 10
first_nNumber of oldest rows to takePositive integer, or use last_n
last_nNumber of newest rows to takePositive integer, or use first_n
aggregationsFunction and columns for each aggregationUp to 10
filtersOptional row filters=, !=, >, >=, <, <=, BETWEEN, IN, LIKE, IS, IS NULL, IS NOT NULL
response body

{
"sensor_a": {
"last_n": {
"favg_temperature": 22.4,
"max_pressure": 1014.6
}
}
}

POST /row_hashes​

Returns a hash of each row in log ID order, one page at a time​

request body

{ "hash_algorithm": "md5" }

KeyDescriptionAllowed Values
hash_algorithmHash function applied to each rowmd5, sha, sha256
continueOptional. Send back the continue value from the previous response to get the next pageValue from previous response
response body

{
"columns": ["log_id", "sensor_id", "temperature", "humidity", "pressure", "timestamp"],
"rows": [
{ "log_id": 1, "hash": "9e107d9d372bb6826bd81d3542a419d6" },
{ "log_id": 5, "hash": "e4d909c290d0fb1ca068ffaddf22cbd0" }
],
"continue": "eyJhZnRlciI6NX0"
}

KeyDescription
columnsColumns included in each hash, in order
rowsLog ID and hash for each row, in log ID order
continueValue to send back for the next page. Null when there are no more rows

GET /health​

Checks that the server is up and can read the database​

response body

{ "status": "ok" }