Skip to main content

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 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.orders WHERE order_date >= DATE '2024-01-01'",
"filename": "orders_2024"
}
FieldTypeRequiredDescription
sqlstringSQL query to execute
filenamestringOutput filename without extension (defaults to download)

Example Response

✅ Success (200 OK)

Returns a streamed CSV file with headers:

HeaderValue
Content-Typetext/csv
Content-Dispositionattachment; 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