CSV Download API
Execute SQL queries against Trino and download results as CSV files. The response is streamed for efficient handling of large datasets.
Endpoint
POST https://<tenant>-trino-stream.<env>.promethium.ai/query/download/csv
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 streamed CSV file with headers:
| Header | Value |
|---|---|
Content-Type | text/csv |
Content-Disposition | attachment; filename=orders_2024.csv |
customer_id,customer_name,order_date,total_amount
1001,Alice Johnson,2024-01-15,250.00
1002,Bob Smith,2024-01-16,175.50
1003,Carol Williams,2024-01-17,320.75
Example: curl
curl -X POST https://<tenant>-trino-stream.<env>.promethium.ai/query/download/csv \
-H "Content-Type: application/json" \
-H "idtoken: YOUR_ID_TOKEN_HERE" \
-d '{
"sql": "SELECT * FROM tpch.sf1.orders LIMIT 1000",
"filename": "orders_report"
}' \
--output orders_report.csv