Streaming with SSE
Rather than polling for the latest telemetry, you can receive live messages from units and vehicles in near-real time using Server-Sent Events (SSE).
Server-Sent Events is a standard describing how servers can initiate data transmission towards clients once an initial client connection has been established. In the browser this is consumed through the native
EventSourceJavaScript API.
How it works
- Request a subscription token for the unit or vehicle you want to follow.
- Open an
EventSourceconnection using that token. - Receive events as the server pushes telemetry, without polling.
1. Request a subscription token
For a unit:
GET /api/v1/monitoring/unit/{unit_id}
For a vehicle's primary unit:
GET /api/v1/monitoring/vehicle/{vehicle_id}/primary
Both require your normal bearer Authorization header and return a short-lived
subscription token used to open the stream.
2. Subscribe with EventSource
// Browser example
const source = new EventSource(
`https://www.acmdestiny.net/api/v1/monitoring/stream?token=${subscriptionToken}`
);
source.onmessage = (event) => {
const telemetry = JSON.parse(event.data);
console.log('Live telemetry:', telemetry);
};
source.onerror = (err) => {
console.error('Stream error — EventSource will attempt to reconnect.', err);
};
The exact stream URL and event names are defined in the SSE section of the API Reference. Treat the snippet above as the shape of the integration, and confirm the precise path against the reference for your deployment.
When to use SSE vs the History Query API
- SSE — live, ongoing telemetry as it happens.
- History Query API — retrospective queries over a past time range.