> For the complete documentation index, see [llms.txt](https://docs.overtime.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overtime.io/overtime-v2-integration/overtime-v2-live-markets-stream-protected.md).

# Overtime V2 live markets stream (protected)

Get a list of all live markets incrementally.

<mark style="color:green;">`GET`</mark>  `https://api.overtime.io/overtime-v2/networks/{network}/live-markets-stream`

A Server-Sent Events (SSE) stream of the live markets, the streaming version of `/live-markets`. It sends the full state on connect, then only the games that changed. Requires the `x-api-key` header.

Each market has the same shape as in the `/live-markets` response: one entry per game with its child markets (including live SGP markets), scores, game clock, period and `tournamentName`. Optimism, Arbitrum and Base stream the same live markets.

#### Path variables

`network` (required): `10` Optimism, `42161` Arbitrum, `8453` Base, `11155420` Optimism Sepolia.

### Example request <a href="#response-parameters" id="response-parameters"></a>

<https://api.overtime.io/overtime-v2/networks/10/live-markets-stream?sport=Basketball>

### Request Parameters (as query string) <a href="#response-parameters" id="response-parameters"></a>

<table><thead><tr><th width="223">Name</th><th width="195">Type</th><th>Description</th></tr></thead><tbody><tr><td>sport</td><td>string</td><td>Only markets of this sport. One sport per request.</td></tr><tr><td>leagueIds</td><td>string (comma-separated league IDs)</td><td>With <code>sport</code>, at least one of them must be a league of that sport.</td></tr><tr><td>typeIds</td><td>string (comma-separated market type IDs)</td><td>Only child markets of these types are kept, and games without any matching market are left out.</td></tr></tbody></table>

### Stream events <a href="#stream-events" id="stream-events"></a>

| Event       | Data                                                                | When                                                                                                                                                                                                      |
| ----------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `snapshot`  | `{ "version": n, "markets": [ ... ] }`                              | Right after connecting, and again to resync a client that fell behind. Replace the whole local state with it.                                                                                             |
| `update`    | `{ "version": n, "upserted": [ ... ], "removed": [ gameId, ... ] }` | When something changed (checked every second). `upserted` holds whole games (the parent market with all its child markets) to add or replace by `gameId`. `removed` holds the gameIds of games to delete. |
| `reconnect` | `{}`                                                                | The connection reached its maximum lifetime (16 to 20 minutes) and is closed right after. Reconnect; a new `snapshot` follows.                                                                            |
| `: ping`    | Comment line, no event                                              | Every 15 seconds, to keep idle connections open through proxies. Ignore it.                                                                                                                               |

* `version` goes up by one with each update. The order of markets isn't kept.
* The stream is gzip-compressed when the client sends `Accept-Encoding: gzip`.

#### Errors

| Status | Meaning                                                                                                                           |
| ------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | Invalid parameter: an unsupported network, sport, league ID or type ID, or a parameter sent twice. The message names the problem. |
| `404`  | The stream is turned off. Poll `/markets` or `/live-markets` instead.                                                             |
| `503`  | Too many stream connections. Poll the regular endpoint and try the stream again later.                                            |

#### Example events

```
event: snapshot
data: {"version":12,"markets":[{"gameId":"0x3230...","leagueId":2, ... }]}

event: update
data: {"version":13,"upserted":[{"gameId":"0x3230...","leagueId":2, ... }],"removed":["0x3130..."]}

: ping

event: reconnect
data: {}
```
