Skip to main content

Streaming Query API

Execute SQL queries against Trino and receive results in real-time via Server-Sent Events (SSE). This endpoint streams data as it becomes available, making it ideal for large result sets and real-time applications.

info

This API is primarily meant to be used from Web UI applications.


Endpoint

POST https://<tenant>-trino-stream.<env>.promethium.ai/query

Headers

Header NameValueRequiredDescription
Content-Typeapplication/jsonRequest body format
idtoken<authentication_id_token>JWT token obtained via login

See Trino Stream Authentication for alternative authentication methods (HTTP Basic, Bearer token).


Request Body

{
"sql": "SELECT * FROM catalog.schema.table LIMIT 100",
"size": 1000
}
FieldTypeRequiredDescription
sqlstringSQL query to execute
sizeintegerMaximum number of rows to return (minimum: 1)

Response

The response is a stream of Server-Sent Events (SSE) with Content-Type: text/event-stream.

Event Types

TypeDescription
metadataColumn definitions (sent first)
rowIndividual data row
completeQuery completed successfully
errorQuery execution error

Example Response

✅ Success (200 OK)

data: {"columns": [{"name": "customer_id", "type": "bigint"}, {"name": "customer_name", "type": "varchar"}], "type": "metadata"}

data: {"data": {"customer_id": 1001, "customer_name": "Alice Johnson"}, "type": "row"}

data: {"data": {"customer_id": 1002, "customer_name": "Bob Smith"}, "type": "row"}

data: {"type": "complete"}

Example: curl

curl -X POST https://<tenant>-trino-stream.<env>.promethium.ai/query \
-H "Content-Type: application/json" \
-H "idtoken: YOUR_ID_TOKEN_HERE" \
-d '{
"sql": "SELECT * FROM tpch.sf1.customer LIMIT 10",
"size": 10
}'