Saltar al contenido principal

GET /api/chain/:slug/explore/sse

Live SSE stream of chain transitions for one state machine. Heartbeats every 30 s. optionalAuth. Public machines accept anonymous; private machines accept either the cookie or ?token=<jwt> (since EventSource cannot send custom headers).

Query

ParamTypeRequiredNotes
tokenstringoptionalBearer JWT for private machines from EventSource (no header support).

Response

HTTP/1.1 200 OK
Content-Type: text/event-stream
Cache-Control: no-cache, no-transform
Connection: keep-alive

:ready

data: {"slug":"my-iot-fleet","type":"event","zeqond":2287439213,"stateHash":"0123…","transitionId":"uuid"}

:heartbeat

JavaScript

const es = new EventSource(
`https://zeqapi.com/api/chain/my-iot-fleet/explore/sse?token=${jwt}`,
);
es.onmessage = (e) => {
const tx = JSON.parse(e.data);
console.log(tx.zeqond, tx.type, tx.stateHash);
};

Notes

Subscribes to the per-machine Redis channel (zeq:chain:event:{machineId}) plus a local in-process bus (for dev mode without Redis). The stream multiplexes both. req.on('close') fires on disconnect; the handler unsubscribes both, no leak.