JSON Download API
Execute SQL queries against Trino and download results as JSON files. The response includes column metadata and data rows in a structured format.
Endpoint
POST https://<tenant>-trino-stream.<env>.promethium.ai/query/download/json
Headers
| Header Name | Value | Required | Description |
|---|---|---|---|
Content-Type | application/json | ✅ | Request 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.orders WHERE order_date >= DATE '2024-01-01'",
"filename": "orders_2024"
}
| Field | Type | Required | Description |
|---|---|---|---|
sql | string | ✅ | SQL query to execute |
filename | string | ❌ | Output filename without extension (defaults to download) |
Example Response
✅ Success (200 OK)
Returns a JSON file with headers:
| Header | Value |
|---|---|
Content-Type | application/json |
Content-Disposition | attachment; filename=orders_2024.json |
{
"metadata": {
"columns": [
{"name": "order_id", "type": "bigint"},
{"name": "customer_name", "type": "varchar"},
{"name": "order_date", "type": "date"},
{"name": "total_amount", "type": "decimal(10,2)"}
],
"type": "metadata"
},
"data": [
{"order_id": 1001, "customer_name": "Alice Johnson", "order_date": "2024-01-15", "total_amount": 250.00},
{"order_id": 1002, "customer_name": "Bob Smith", "order_date": "2024-01-16", "total_amount": 175.50}
]
}
Response Fields
| Field | Type | Description |
|---|---|---|
metadata | object | Query metadata including column information |
metadata.columns | array | List of column definitions |
metadata.columns[].name | string | Column name |
metadata.columns[].type | string | Column data type |
data | array | Array of row objects with column-value pairs |
error | string | Error message if query failed (only present on error) |
Example: curl
curl -X POST https://<tenant>-trino-stream.<env>.promethium.ai/query/download/json \
-H "Content-Type: application/json" \
-H "idtoken: YOUR_ID_TOKEN_HERE" \
-d '{
"sql": "SELECT * FROM tpch.sf1.orders LIMIT 100",
"filename": "orders_data"
}' \
--output orders_data.json