Appearance
Stream Server-Sent Events
Subscribe to events from a stream using Server-Sent Events (SSE) protocol.
Request
http
GET /v4/stream/{stream}/sse?start_tx={start_tx}
Accept: text/event-stream
Authorization: Bearer <api_key>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| stream | string | Yes | Stream name to subscribe to |
| start_tx | int64 | No | Event ID to start subscribing from. If not provided, subscribes to new events only |
Response
Server sends events in SSE format with data field containing JSON object:
ts
{
tx: number,
data: any,
binary: boolean
}| Field | Type | Description |
|---|---|---|
| tx | number | ID of the event |
| data | any | Event data - string, JSON object, or base64 encoded binary data |
| binary | boolean | Indicates if the event data is in binary format. |
Example
Request:
bash
curl --location 'https://api.litebase.io/v4/stream/sample/sse' \
--header 'Accept: text/event-stream' \
--header "Authorization: Bearer $LITEBASE_API_KEY"Response stream:
data: {"tx":1,"data":"hello world"}
data: {"tx":2,"data":{"name":"Braavos","type":"city_created"}}
data: {"tx":3,"data":"base64EncodedBinaryData"}