SSE Streaming API

Lightweight, one-way real-time data streaming using Server-Sent Events.

SkySpy provides a Server-Sent Events (SSE) stream for applications that only need to receive data. SSE is a lightweight alternative to Socket.IO, supported natively in all browsers without additional libraries.

%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#1e3a5f', 'primaryTextColor': '#fff', 'primaryBorderColor': '#3b82f6', 'lineColor': '#60a5fa'}}}%%
flowchart LR
    subgraph Server["🖥️ SkySpy API"]
        DATA["📡 Live Data"]
        SSE["📤 SSE Endpoint"]
    end

    subgraph Clients["📱 Your Apps"]
        BROWSER["🌐 Browser"]
        PYTHON["🐍 Python Script"]
        CURL["💻 curl"]
    end

    DATA --> SSE
    SSE -->|"📨 One-way stream"| BROWSER
    SSE -->|"📨 One-way stream"| PYTHON
    SSE -->|"📨 One-way stream"| CURL

    style Server fill:#0d4f8b,stroke:#3b82f6,stroke-width:2px,color:#fff
    style Clients fill:#065f46,stroke:#10b981,stroke-width:2px,color:#fff

Quick Start

Connect using the native browser EventSource API — no libraries required:

const stream = new EventSource('http://localhost:5000/api/v1/map/sse');

stream.addEventListener('aircraft_update', (event) => {
  const data = JSON.parse(event.data);
  console.log('Aircraft:', data.aircraft);
});

stream.addEventListener('safety_event', (event) => {
  const alert = JSON.parse(event.data);
  console.warn('Safety:', alert.message);
});

Connection

SettingValue
EndpointGET /api/v1/map/sse
Content-Typetext/event-stream

Query Parameters

ParameterTypeDefaultDescription
replay_historybooleanfalse📜 Replay buffered events on connect

Events


Comparison: SSE vs Socket.IO

FeatureSSESocket.IO
DirectionServer → Client onlyBi-directional
Request/Response❌ No✅ Yes
Weather API❌ No✅ Yes
Browser SupportNative EventSourceRequires library
Best ForSimple dashboardsFull-featured apps

Implementation


Next Steps