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
| Setting | Value |
|---|---|
| Endpoint | GET /api/v1/map/sse |
| Content-Type | text/event-stream |
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
replay_history | boolean | false | 📜 Replay buffered events on connect |
Events
Comparison: SSE vs Socket.IO
| Feature | SSE | Socket.IO |
|---|---|---|
| Direction | Server → Client only | Bi-directional |
| Request/Response | ❌ No | ✅ Yes |
| Weather API | ❌ No | ✅ Yes |
| Browser Support | Native EventSource | Requires library |
| Best For | Simple dashboards | Full-featured apps |
Implementation
Next Steps
Updated 7 days ago