Skip to content

Querying Stored Data

SSE and polling deliver events live, as they happen. To query data that RT Server has already recorded — past events, aggregated analytics, and object tracks — use the Database API under the /v1/database namespace.

These endpoints are all POST (the query is in the request body) and each returns a { "data": [ ... ] } object. Timestamps are ISO 8601 with a timezone.

Raw events

Return individual stored events, newest first:

curl -X POST "http://localhost:3546/v1/database/events" \
  -H "Content-Type: application/json" \
  -d '{
    "timeRange": { "startTime": "2026-06-19T00:00:00Z", "endTime": "2026-06-19T23:59:59Z" },
    "filters": { "event_type": "Line Crossing" },
    "orderBy": "system_timestamp desc",
    "limit": 100
  }'

Useful fields: filters narrows by column (for example event_type, trigger_name, instance_id); columns selects which fields to return; limit/offset (or the afterId cursor) page through results.

Aggregated analytics

Compute counts and aggregates grouped over time or by attribute:

curl -X POST "http://localhost:3546/v1/database/analytics" \
  -H "Content-Type: application/json" \
  -d '{
    "metrics": { "total_events": { "function": "count" } },
    "timeRange": { "startTime": "2026-06-19T00:00:00Z", "endTime": "2026-06-19T23:59:59Z" },
    "groupBy": ["event_type"],
    "interval": { "unit": "hour", "size": 1 }
  }'

metrics is a map of result-name to { function, field }, where function is one of count, sum, avg, min, max, percentage (field is required for everything except count). interval.unit is one of minute, hour, day, week, month, year. groupBy accepts up to three fields.

Tracks (for heatmaps and replay)

Return the recorded positions of tracked objects over time:

curl -X POST "http://localhost:3546/v1/database/tracks" \
  -H "Content-Type: application/json" \
  -d '{
    "instanceId": "<instanceId>",
    "timeRange": { "startTime": "2026-06-19T00:00:00Z", "endTime": "2026-06-19T23:59:59Z" },
    "limit": 10000
  }'

Returns { "meta": [...], "locations": [...] }, where each location carries normalized x, y, width, height and a system_timestamp. At least one of trackingId or instanceId is required, along with timeRange.

Next steps