Realtime Traffic Metrics

GET /v1/traffic/metrics/realtime

Server-Sent Events (SSE) stream of the same aggregate metric object as /traffic/metrics, computed over a fixed rolling 5-minute window across your active account. The response is text/event-stream: read data: events rather than parsing a single JSON body. For arbitrary hour/day windows, use /traffic/metrics.

Designed for live dashboards. The window and endpoint filter are not configurable on this route — it always reports the last 5 minutes account-wide.

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)

Each 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": [...]}
Iris