Skip to main content

Overview

/api/events is a Server-Sent Events (SSE) endpoint that streams a lightweight notification whenever any device’s state changes. Use it to keep a UI or integration updated without polling /status repeatedly.

Endpoint

Response

The endpoint sends an SSE stream. Each event has:
The event payload only contains the serial number of the device that changed. To get the new state, follow up with a GET /status?serial={serial} call.

Response Headers

The X-Accel-Buffering: no header is included for nginx compatibility. Without it, nginx may buffer the stream and delay delivery of events.

Examples

Behavior

  • The connection stays open indefinitely until the client disconnects.
  • Events are emitted whenever a device state change is processed (subscribe PUT, command execution).
  • There is no initial burst of events on connection — only future changes are sent.
  • If the server restarts, the SSE connection will drop and the client must reconnect.

Use Case: Live Dashboard

GET /status

Get full device state after an event

POST /notify-device

Manually trigger a push to subscribers