Nimbuz API Docs
Guides

Live streams (SSE)

StreamEndpoint
Deployment or tool metricsGET /metrics/v1/resources/live
Environment metricsGET /metrics/v1/namespace/live
Deployment statusGET /deployment/v1/live/deployment/stream
Tool statusGET /deployment/v1/live/tools/stream

Each stream sends an update event as soon as you connect, then one every interval seconds (minimum 15). A keep-alive comment arrives every 20 seconds, and errors arrive as event: error.

Code
event: update data: {"ts":1730800000,"identity":{"namespace":"env-k3x9q2m7","resourceType":"cpu"},"values":{"usage":42.5,"request":250,"limit":500}}

Streams need the Authorization header. The browser EventSource API can't send headers, so use fetch:

async function stream(url, token, onEvent, signal) { const res = await fetch(url, { headers: { Authorization: `Bearer ${token}`, Accept: "text/event-stream" }, signal, }); const reader = res.body.pipeThrough(new TextDecoderStream()).getReader(); let buf = ""; for (;;) { const { value, done } = await reader.read(); if (done) break; buf += value; let i; while ((i = buf.indexOf("\n\n")) !== -1) { const frame = buf.slice(0, i); buf = buf.slice(i + 2); const event = /^event: (.*)$/m.exec(frame)?.[1] ?? "message"; const data = /^data: (.*)$/m.exec(frame)?.[1]; if (data) onEvent(event, JSON.parse(data)); } } }

If the connection drops, reconnect after about 5 seconds. If you get 401, log in again first.