Trasys
Public API

TQL Queries

Execute TQL SELECT queries against your traces, logs, metrics, AI spans, and HTTP requests directly through the Trasys Public API's POST /v1/tql endpoint.

POST /v1/tql

Execute a TQL (Trasys Query Language) SELECT query against your project data. This is the same engine powering the in-app TQL Editor — anything you can run there, you can run here.

Request body

FieldTypeRequiredDescription
querystringYesTQL SELECT statement (max 50,000 characters)

Example

curl -X POST \
  -H "X-API-Key: sk_prod_..." \
  -H "Content-Type: application/json" \
  -d '{"query": "SELECT service_name, count() AS reqs FROM traces GROUP BY service_name ORDER BY reqs DESC LIMIT 10"}' \
  "http://localhost:3000/v1/tql"

Response

{
  "columns": [
    { "name": "service_name", "type": "String" },
    { "name": "reqs", "type": "UInt64" }
  ],
  "rows": [
    ["api-server", 12400],
    ["worker", 3200]
  ],
  "rowCount": 2,
  "durationMs": 38,
  "truncated": false
}

Available tables

TableDescription
tracesDistributed trace spans
logsApplication log entries
metricsCustom metric data points
ai_spansLLM/agent spans with token counts
http_requestsPre-aggregated HTTP request summary
error_groupsGrouped error occurrences

Row limit

TQL API responses are capped at 10,000 rows. If your query would return more, the truncated field will be true. Add LIMIT to your query to stay within bounds.

Only SELECT queries are permitted. INSERT, ALTER, DROP, and other write operations are rejected with 400 Bad Request.

Example queries

Error rate by service in the last hour

SELECT
  service_name,
  countIf(status = 'error') AS errors,
  count() AS total,
  round(countIf(status = 'error') / count() * 100, 2) AS error_rate_pct
FROM traces
WHERE timestamp >= now() - INTERVAL 1 HOUR
GROUP BY service_name
ORDER BY error_rate_pct DESC

P95 latency by endpoint

SELECT
  operation_name,
  quantile(0.95)(duration_ms) AS p95_ms,
  count() AS requests
FROM traces
WHERE timestamp >= now() - INTERVAL 24 HOUR
GROUP BY operation_name
ORDER BY p95_ms DESC
LIMIT 20

Recent errors with messages

SELECT timestamp, service_name, level, message
FROM logs
WHERE level = 'error'
  AND timestamp >= now() - INTERVAL 1 HOUR
ORDER BY timestamp DESC
LIMIT 50

On this page