# Follow the timeline live (server-sent events).

> Each message has `id: <seq>`, `event: event` and the timeline event as JSON in `data`.
> https://koi.dog/docs/api/events/stream-events/

`GET /api/v1/events/stream` · Scope: `read`

Takes the same filters as `GET /events`. Reconnect with the `Last-Event-ID` header (or `after=<seq>`) to replay everything missed, in order, before going live; without either the stream starts at now. A comment line every 15 seconds keeps the connection open. A key may hold 8 streams at once. No path parameters.

## Query parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `crewId` | `string` | no | Only those of this crew. At least 5 characters. |
| `taskId` | `string` | no | Only those of this task. At least 5 characters. |
| `agentId` | `string` | no | Only those of this agent. At least 5 characters. |
| `runId` | `string` | no | Only those of this run. At least 5 characters. |
| `nodeId` | `string` | no | Only those of this machine. At least 5 characters. |
| `vmId` | `string` | no | Only those of this VM. At least 5 characters. |
| `kind` | `array` | no | One or more values, comma-separated. For events: exact kinds or prefixes such as `run.*`. 1 to 30 items. |
| `level` | `array` | no | One or more levels, comma-separated. Any of `info`, `warn`, `error`. At least 1 item. |
| `after` | `integer` | no | Only events with a `seq` greater than this. ≥ 0. |
| `signals` | `boolean` | no | Experimental, for the dashboard: also send `changed` messages naming a record to refetch. Default `false`. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Last-Event-ID` | `string` | no | The `seq` of the last event received; everything after it is replayed. |

## Response.

Server-sent events. Each `data` line is an `Event` as JSON; reconnect with `Last-Event-ID` to be sent what you missed.

## Request.

```sh
curl -N https://app.koi.dog/api/v1/events/stream \
    -H "Authorization: Bearer $KOIDOG_API_KEY"
```

```js
const res = await fetch("https://app.koi.dog/api/v1/events/stream", {
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
  },
});
for await (const chunk of res.body) process.stdout.write(chunk);
```

```python
import os

import requests

r = requests.get(
    "https://app.koi.dog/api/v1/events/stream",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
    stream=True,
)
r.raise_for_status()
for line in r.iter_lines():
    print(line.decode())
```
