Typescript (SDK)
import { Autumn } from 'autumn-js'
const autumn = new Autumn()
const result = await autumn.events.query({
sql: "SELECT event_name, count() AS event_count FROM events GROUP BY event_name",
});from autumn_sdk import Autumn
autumn = Autumn(secret_key="am_sk_test...")
res = autumn.events.query(
sql="SELECT event_name, count() AS event_count FROM events GROUP BY event_name",
)curl --request POST \
--url https://api.useautumn.com/v1/events.query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-api-version: <x-api-version>' \
--data '
{
"sql": "SELECT event_name, count() AS event_count FROM events GROUP BY event_name"
}
'{"type":"columns","columns":[{"name":"event_name","type":"String"},{"name":"event_count","type":"UInt64"}]}
{"type":"row","values":["api_call","42"]}
{"type":"row","values":["message_sent","17"]}
{"type":"end","rows":2,"truncated":false,"stopped_by":null}
{"type":"columns","columns":[{"name":"event_name","type":"String"},{"name":"event_count","type":"UInt64"}]}
{"type":"row","values":["api_call","42"]}
{"type":"error","code":"statement_timeout","message":"Query exceeded the 30s compute limit for your plan and was cancelled. Narrow it (filter by date or customer, select fewer columns, or add LIMIT) or contact support@useautumn.com to raise your compute limit.","details":{"limit_ms":30000}}
Analytics
Query events in SQL
Run a read-only ClickHouse SQL query over your usage events and rollups. Scoped to your organization and environment. SETTINGS clauses are not allowed. Streams compressed newline-delimited JSON; see the events SQL guide.
POST
/
v1
/
events.query
Typescript (SDK)
import { Autumn } from 'autumn-js'
const autumn = new Autumn()
const result = await autumn.events.query({
sql: "SELECT event_name, count() AS event_count FROM events GROUP BY event_name",
});from autumn_sdk import Autumn
autumn = Autumn(secret_key="am_sk_test...")
res = autumn.events.query(
sql="SELECT event_name, count() AS event_count FROM events GROUP BY event_name",
)curl --request POST \
--url https://api.useautumn.com/v1/events.query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-api-version: <x-api-version>' \
--data '
{
"sql": "SELECT event_name, count() AS event_count FROM events GROUP BY event_name"
}
'{"type":"columns","columns":[{"name":"event_name","type":"String"},{"name":"event_count","type":"UInt64"}]}
{"type":"row","values":["api_call","42"]}
{"type":"row","values":["message_sent","17"]}
{"type":"end","rows":2,"truncated":false,"stopped_by":null}
{"type":"columns","columns":[{"name":"event_name","type":"String"},{"name":"event_count","type":"UInt64"}]}
{"type":"row","values":["api_call","42"]}
{"type":"error","code":"statement_timeout","message":"Query exceeded the 30s compute limit for your plan and was cancelled. Narrow it (filter by date or customer, select fewer columns, or add LIMIT) or contact support@useautumn.com to raise your compute limit.","details":{"limit_ms":30000}}
Body Parameters
{"type":"columns","columns":[{"name":"event_name","type":"String"},{"name":"event_count","type":"UInt64"}]}
{"type":"row","values":["api_call","42"]}
{"type":"row","values":["message_sent","17"]}
{"type":"end","rows":2,"truncated":false,"stopped_by":null}
{"type":"columns","columns":[{"name":"event_name","type":"String"},{"name":"event_count","type":"UInt64"}]}
{"type":"row","values":["api_call","42"]}
{"type":"error","code":"statement_timeout","message":"Query exceeded the 30s compute limit for your plan and was cancelled. Narrow it (filter by date or customer, select fewer columns, or add LIMIT) or contact support@useautumn.com to raise your compute limit.","details":{"limit_ms":30000}}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Body
application/json
Read-only ClickHouse SQL over usage events and rollups, scoped to your organization and environment. SETTINGS clauses are not allowed.
Required string length:
1 - 100000Response
200 - application/x-ndjson
A newline-delimited JSON stream. Each line is an AnalyticsQueryLine: columns first, then one row line per result row, then an end or error line.
The response is of type file.