Realtime Traffic Metrics

GET /v1/traffic/metrics/realtime

The same aggregate metric object as /traffic/metrics, computed over the last 5 minutes across your active account, delivered as Server-Sent Events: the response is text/event-stream carrying one data: event, after which the server closes the connection. Poll the route again for fresh values. For arbitrary hour/day windows, use /traffic/metrics.

The window and endpoint filter are not configurable on this route — it always reports the last 5 minutes account-wide. If the metrics can't be computed the response is a 200 with an empty body (no event).

Requires the traffic-inspector read permission on the active account.

Query parameters

None. (Any query parameters are ignored; the window is fixed at the last 5 minutes and is not endpoint-filterable.)

Response (200 OK — text/event-stream)

The data: event contains the same flat metric object documented for /traffic/metrics (total_requests, error_rate, average_response_time, status_code_breakdown, total_bandwidth_in/out, time_series_*, etc.), aggregated over the trailing 5 minutes.

Errors

401 Unauthorized
Missing auth.
403 Forbidden
No active account, not a member, or missing the traffic-inspector read permission.
Request
curl -N "https://api.ngris.com/v1/traffic/metrics/realtime" \ -H "X-API-KEY: <your_api_key>" \ -H "Accept: text/event-stream"
Python — consume the SSE stream
import json, requests with requests.get( "https://api.ngris.com/v1/traffic/metrics/realtime", headers={"X-API-KEY": "<your_api_key>", "Accept": "text/event-stream"}, stream=True, ) as resp: for line in resp.iter_lines(): if line.startswith(b"data: "): m = json.loads(line[len(b"data: "):]) print(f"{m['total_requests']} req err={m['error_rate']:.2f}%")
Response — 200 OK (text/event-stream)
data: {"total_requests": 712, "error_rate": 0.14, "average_response_time": 18.6, "status_code_breakdown": {"success": 705, "redirect": 2, "client_err": 4, "server_err": 1, "other": 0, "total": 712, "success_rate": 99.02}, "total_bandwidth_in": 845221, "total_bandwidth_out": 5120044, "time_series_requests": [{"timestamp": "2026-04-29T13:01:00Z", "label": "Apr 29 13:01", "value": 140}]}
Was this helpful?
Was this helpful?