Stream live updates

Keep a screen live without polling: one stream per project says the moment a charger, a session or a meter reading changes.

2 min readEdit this page
On this page

Open one stream per project and Flowion tells you the moment something changes: a charger comes online, an outlet becomes occupied, a session starts, new meter readings land. Your screen stays live without polling, and without spending your rate limit on guesses.

GET/v1/projects/$PROJECT/live-eventsbash
curl -N "$API/projects/$PROJECT/live-events" \
  -H "Authorization: Bearer $TOKEN"
event: chargingStationConnected
data: {"type":"chargingStationConnected","chargingStationId":"4b1e…"}

-N turns off curl's buffering, so frames show up as they arrive. The stream uses Server-Sent Events: each frame's event: line is its type, and data: is one JSON object with the same type inside.

Refetch what changed

An event names what changed, not the new value. Use its ids to refetch the matching resource — the session, the charger, the outlet — over the API.

Events are delivered best effort, so treat the stream as a reminder rather than a record:

  1. Connect, then load the current state of whatever you show.

  2. On each event, refetch what it names.

  3. After every reconnect, load the current state again.

What arrives

Every event carries chargingStationId. The rest depends on the type; a field that does not apply is left out, never sent as null.

typeAlso carriesMeans
chargingStationConnected—The charger came online
chargingStationDisconnected—The charger went offline
connectorStatusChangedconnectorId, statusA connector changed state: Available, Occupied, Reserved, Unavailable or Faulted
transactionStartedconnectorId, transactionIdA session began
transactionUpdatedconnectorId, transactionIdA session's readings or state changed
transactionEndedconnectorId, transactionIdA session finished
meterValuesUpdatedevseIdNew meter readings for an outlet. Several readings close together arrive as one event
commandStatusChangedcommandIdA command you sent moved to a new status

Read it from a browser

The stream needs the same Authorization header as every other call. A browser's built-in EventSource cannot send one, so read the stream with fetch and split the body into frames yourself, or open the stream on your server and pass the events on.

Stay connected

  • It closes after 30 minutes. Reconnect, and load the current state again as you do.

  • It stays open when quiet. A comment line arrives as soon as you connect and every 15 seconds after, so proxies do not drop an idle connection. Ignore lines that start with :.

  • Access is checked again every 2 minutes. If the caller loses access to the project — removed from it, or its API key revoked — the stream sends one last frame and closes:

event: revoked
data: {"reason":"accessRevoked"}

reason is accessRevoked, or tokenExpired when the token that opened the stream has expired. For tokenExpired, reconnect with a fresh token. For accessRevoked, reconnecting is refused until access is restored.

Endpoints

Live Events

In the API reference