> ## Documentation Index
> Fetch the complete documentation index at: https://enhancedradar.com/docs/api/llms.txt
> Use this file to discover all available pages before exploring further.

# Live updates

> Stream live transcripts, events, flight statuses, airport statuses, and PIREPs over one Enhanced Radar WebSocket.

`GET /api/v0/live` opens one WebSocket. Subscribe to as many topics as you need on the same connection, and unsubscribe when you no longer want one.

| Topic | Streams |
| - | - |
| [`transcripts`](https://enhancedradar.com/docs/api/docs/api/api-reference/live/transcripts) | Each new transmission that passes your filters. |
| [`events`](https://enhancedradar.com/docs/api/docs/api/api-reference/live/events) | Events as they are reported and updated. |
| [`flight_status`](https://enhancedradar.com/docs/api/docs/api/api-reference/live/flight-status) | One flight's status as it changes. |
| [`airport_status`](https://enhancedradar.com/docs/api/docs/api/api-reference/live/airport-status) | One airport's complete status. |
| [`pireps`](https://enhancedradar.com/docs/api/docs/api/api-reference/live/pireps) | Each new PIREP that matches a search. |

## Connect and subscribe

**1. Open the connection**

Send the API key on the upgrade request.

```bash theme={null}
websocat -H "Authorization: Bearer $ER_API_KEY" "wss://api.enhancedradar.com/api/v0/live"
```

**2. Subscribe**

Send `subscribe` with a topic and its `params`. A `request_id` lets you match the reply.

```json theme={null}
{"action": "subscribe", "request_id": "3f9a7c21-5d4e-4b8a-9c6f-0e2d1a7b4c85", "subscription_topic": "transcripts", "params": {"facility_id": "3667d976-1566-4887-ae34-c024d92f46c7"}}
```

**3. Handle updates**

The server replies `subscribed` with a `subscription_id`. Updates then arrive as `update` messages with the payload in `data`. Each `update` also reports `charged_usd`, what that message cost, and, when it was billed, `balance_usd`, your organization's balance after it.

See [Connect](https://enhancedradar.com/docs/api/docs/api/api-reference/live/connect.md) for the full message format.

## Keep the connection alive

* An idle connection can be closed by the network between you and the API.
* Send a WebSocket ping at least every 30 seconds. The server answers each ping with a pong.
* The server sends no messages of its own while nothing matches, so don't rely on updates to keep the connection open.

## Reconnect

Reconnect whenever the connection closes. Subscriptions belong to the connection, so subscribe again after reconnecting.

* There is no backfill: only what happens after a subscription starts is sent. Use the pull endpoints, such as [`GET /api/v0/transcripts`](https://enhancedradar.com/docs/api/docs/api/api-reference/transcripts/list), to fill any gap.
* A client that falls 256 messages behind across all its subscriptions, or that does not accept a message within one second, is disconnected. Read messages promptly.
* A client message over 4 KiB closes the connection.
* Subscribing to `flight_status` or `airport_status` again sends, and charges, a new first update. See [Billing](https://enhancedradar.com/docs/api/docs/api/concepts/billing.md).
* A subscription can also end without the connection closing: when the charge for an update is refused, the server sends `unsubscribed` with an `error`. Resolve the cause it names, such as an insufficient balance, before subscribing again.

## Order and replace updates

| Topic | How to handle updates |
| - | - |
| `transcripts` | Order by `received_at`. |
| `events` | Replace an earlier message for the same `event_id` with the newer one. |
| `flight_status` | Order by `status_at`. |
| `airport_status` | Replace the previous status. Use `generated_at` to ignore one older than a status you already have. |
| `pireps` | Order by `happened_at`; updates arrive in the order PIREPs are stored. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.