Skip to content

Events#

A live or replayed stream of changes to the shared model.

The change event#

The data of an event. Event names are entity.snapshot, snapshot.complete, entity.created, entity.updated, entity.removed, and stream.overflow, sent before the server closes a stream that has fallen more than 10,000 events behind.

Attributes#

revisionintegerrequired
entityobject | entity ID
The full entity on entity.snapshot and entity.created; its ID otherwise.
changedobject
On entity.updated
observationobservation ID
observed_attimestamp
RFC 3339 in UTC, with up to millisecond precision.
countinteger
On snapshot.complete
detailstring
On stream.overflow

Change event

"id: 7:48213377\nevent: entity.snapshot\ndata: {\"revision\":48213377,\"entity\":{\"id\":\"aircraft:8851a4\",\"type\":\"aircraft\",\"label\":\"HS-THB\",\"position\":{\"lat\":13.69212,\"lon\":100.75391},\"attributes\":{\"movement\":\"parked\",\"stand\":\"stand:C2\"}}}\n\nid: 7:48213377\nevent: snapshot.complete\ndata: {\"revision\":48213377,\"count\":214}\n\nid: 7:48213421\nevent: entity.updated\ndata: {\"revision\":48213421,\"entity\":\"aircraft:8851a4\",\"changed\":{\"movement\":\"pushback\",\"ground_speed_kt\":2},\"observation\":\"obs_1Mz5Rf8kW3ta\",\"observed_at\":\"2026-11-23T02:58:44.900Z\"}\n"

Stream changes#

GET/v1/airports/{airport}/events

Opens a server-sent events stream of changes to the shared model. Without from, the stream starts with a snapshot of matching entities and then follows live changes. With from, it replays history from that instant at speed times real time and, if until is omitted, continues live once it catches up.

Each event's id is epoch:revision. Reconnect with Last-Event-ID to resume without gaps, on the edge or on the on-premise node.

Requires events:read.Preview 1

Path parameters#

airportICAO coderequired
The airport's ICAO code.

Query parameters#

typescomma-separated enums
Comma-separated entity types to include. Values: aircraft, flight, vehicle, person, stand, runway, taxiway, area, airport.
bboxstring
Only changes to entities inside this box, as min_lon,min_lat,max_lon,max_lat.
fromtimestamp
Replay from this instant. Omit to start live.
untiltimestamp
End a replay at this instant and close the stream.
speednumber
Replay speed as a multiple of real time, from 1 to 60. Ignored for live streams. Default 1.
orderenum
For replays. observed sends changes in observed_at order, using everything received so far. received sends them in the order they arrived, leaving out anything received after the instant being replayed. One of observed, received. Default observed.
snapshotboolean
Send the state of every matching entity as entity.snapshot events before the first change. Default true.

Headers#

Last-Event-IDstring
Resume after this event, as epoch:revision. Takes precedence over from.

Response#

200 An open event stream. A comment line is sent every 15 seconds to keep idle connections open. Returns change event.

curl -N https://api.surfacelens.app/v1/airports/VTBS/events?types=aircraft,vehicle \
  -H "Authorization: Bearer $SURFACELENS_KEY"
const res = await fetch(
  "https://api.surfacelens.app/v1/airports/VTBS/events?types=aircraft,vehicle",
  { headers: { Authorization: `Bearer ${process.env.SURFACELENS_KEY}` } },
);

const lines = res.body!.pipeThrough(new TextDecoderStream());
let buffer = "";
for await (const chunk of lines) {
  buffer += chunk;
  let end;
  while ((end = buffer.indexOf("\n\n")) >= 0) {
    const frame = buffer.slice(0, end);
    buffer = buffer.slice(end + 2);
    const event = /^event: (.+)$/m.exec(frame)?.[1];
    const data = /^data: (.+)$/m.exec(frame)?.[1];
    if (event && data) console.log(event, JSON.parse(data));
  }
}
import json, os, httpx

url = "https://api.surfacelens.app/v1/airports/VTBS/events"
headers = {"Authorization": f"Bearer {os.environ['SURFACELENS_KEY']}"}

with httpx.stream("GET", url, params={"types": "aircraft,vehicle"},
                  headers=headers, timeout=None) as res:
    event = None
    for line in res.iter_lines():
        if line.startswith("event: "):
            event = line[7:]
        elif line.startswith("data: "):
            print(event, json.loads(line[6:]))

Response200

id: 7:48213377
event: entity.snapshot
data: {"revision":48213377,"entity":{"id":"aircraft:8851a4","type":"aircraft","label":"HS-THB","position":{"lat":13.69212,"lon":100.75391},"attributes":{"movement":"parked","stand":"stand:C2"}}}

id: 7:48213377
event: snapshot.complete
data: {"revision":48213377,"count":214}

id: 7:48213421
event: entity.updated
data: {"revision":48213421,"entity":"aircraft:8851a4","changed":{"movement":"pushback","ground_speed_kt":2},"observation":"obs_1Mz5Rf8kW3ta","observed_at":"2026-11-23T02:58:44.900Z"}