# Live streams (SSE) (/docs/api/live-streams)

Subscribe to live tournament match, playday, and broadcast updates over Server-Sent Events.

Server-Sent Events (SSE) let browsers, scoreboards, and lightweight services
react to live tournament changes without hosting a public webhook endpoint.

## Stream endpoints [#stream-endpoints]

Strave exposes two SSE endpoints with the same event envelope:

- Production: `GET https://strave.gg/api/v2/events/{eventId}/stream` (requires
  the `event:read` scope; adds broadcast and playday updates when the token also
  has `broadcast:read`).
- Sandbox: `GET https://strave.gg/api/v2/sandbox/events/{eventId}/stream` (zero
  cost, emits simulated score ticks).

## Event types [#event-types]

Each frame carries an `id`, an `event` name, and a JSON `data` envelope with
`id`, `type`, `eventId`, `occurredAt`, `revision`, and `data`.

| Event               | When Strave emits it                                           |
| ------------------- | -------------------------------------------------------------- |
| `snapshot`          | Once on connect with the current event, matches, and playdays. |
| `event.updated`     | The event revision advanced.                                   |
| `match.updated`     | A match score, status, or schedule revision advanced.          |
| `broadcast.updated` | Broadcast identity or overlay metadata changed.                |
| `playday.updated`   | Live playday state or overlay score changed.                   |
| `reconnect`         | Sent before a serverless connection window ends so you resume. |

## Consume a stream with `@strave/sdk` [#consume-a-stream-with-stravesdk]

Both SDK flavours parse SSE frames and send `Last-Event-ID` automatically when
reconnecting after a `reconnect` frame.

```ts
import { createStraveClient } from "@strave/sdk";

const strave = createStraveClient({ sandbox: true });

for await (const frame of strave.events.stream("event_sbx_eml_s7", {
	maxReconnects: 5,
})) {
	console.log(frame.type, frame.revision);
}
```

With Effect v4 (`@strave/sdk/effect`), consume the stream as a `Stream`:

```ts
import { Effect, Stream } from "effect";
import { StraveClient } from "@strave/sdk/effect";

const watch = Effect.gen(function* () {
	const strave = yield* StraveClient;
	yield* strave
		.streamEvent("event_sbx_eml_s7")
		.pipe(Stream.runForEach((frame) => Effect.logInfo(frame.type)));
}).pipe(Effect.provide(StraveClient.layer({ sandbox: true })));
```

## Watch from your terminal [#watch-from-your-terminal]

You can stream live updates straight to your terminal with the Strave CLI:

```sh
bunx @strave/cli matches watch event_sbx_eml_s7 --sandbox
```

## Next steps [#next-steps]

- Learn about [Broadcast control](/docs/api/broadcast-control) to update live
  playday scores.
- Use [SDKs and packages](/docs/api/sdks) to install `@strave/sdk`.