Query with HTTP API
The HTTP API provides a lightweight interface for querying Altertable.
With the HTTP API, you can:
- Run SQL queries over HTTPS
- Stream results as JSONL
Quick start
Results stream as JSONL, so you can process rows as they arrive instead of buffering the full response. Run SQL with cURL or SDKs:
cURL
# echo -n "your_lakehouse_username:your_lakehouse_password" | base64ALTERTABLE_BASIC_AUTH_TOKEN="your_base64_token"curl https://api.altertable.ai/query \-H "Authorization: Basic $ALTERTABLE_BASIC_AUTH_TOKEN" \-d '{"statement": "SELECT event, COUNT(*) AS count FROM product_analytics.main.events GROUP BY event"}'
SDKs
Installation
pip install altertable-lakehouse
Usage
from altertable_lakehouse import Clientfrom altertable_lakehouse.models import QueryRequestclient = Client(username="your_lakehouse_username",password="your_lakehouse_password",)# Run a SQL queryreq = QueryRequest(statement="""SELECTdate_trunc('day', timestamp) AS day,COUNT(DISTINCT user_id) AS dauFROM eventsWHERE event = 'Event Name'AND timestamp >= NOW() - INTERVAL '30 days'GROUP BY 1ORDER BY 1 DESC""")# Accumulate all rows in memoryresult = client.query_all(req)for row in result.rows:print(row)
API reference
Use the reference page for endpoint details, payload shapes, and full examples:
The same reference also covers related ingest, validation, and task endpoints: