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

# Real-time stream (SSE)

> Receive odds movements pushed via Server-Sent Events, no polling.

`/api/stream` is a **Server-Sent Events** stream: on connection you receive a snapshot of the board, then each change is **pushed** (no polling).

Since `EventSource` doesn't allow a custom header, pass the key in the query: `?key=YOUR_KEY`.

```javascript Node.js theme={null}
import { EventSource } from "eventsource";

const es = new EventSource("https://api.apinn.io/api/stream?key=YOUR_KEY");

es.addEventListener("snapshot", (e) => {
  const { events } = JSON.parse(e.data);
  console.log("initial snapshot:", events.length, "matches");
});

es.addEventListener("update", (e) => {
  const { events } = JSON.parse(e.data);
  // events = matches whose main odds have changed
});

es.addEventListener("remove", (e) => {
  const { ids } = JSON.parse(e.data);
  // matches removed from the board (ended)
});
```

## Event types

| Event      | Payload             | Meaning                                   |
| ---------- | ------------------- | ----------------------------------------- |
| `snapshot` | `{ events: [...] }` | Initial state of the board on connection. |
| `update`   | `{ events: [...] }` | Matches whose main odds have moved.       |
| `remove`   | `{ ids: [...] }`    | Matches removed (ended).                  |

Each `events` element carries the `event_id`, the teams, the `live_status` and the main odds (moneyline/spread/totals).

<Tip>
  The stream opens a long-lived connection and counts as **1 request** at the moment of connection.
</Tip>
