Stream Quickstart

Send and subscribe to real-time events.

Quickstart

Litebase Stream gives you real-time, append-only streams — over plain HTTP.

Think of it like a rebel command feed. Every message you send is preserved. Any system — dashboard, agent, or droid — can subscribe and respond in real time. There’s no broker to install, no infrastructure to manage, and no SDK required. Just curl, fetch, or your favorite HTTP client.

1. Publish your first event

Streams are append-only logs. You don’t need to pre-create a stream — just start writing to one.

curl -X POST https://api.litebase.io/v4/stream/starwars \
  -H "Authorization: Bearer $LITE_API_KEY" \
  -H "Content-Type: text/plain" \
  --data "Help me Obi-Wan Kenobi. You’re my only hope."

This sends a simple text event to the starwars stream.

2. Subscribe to real-time updates

Open another terminal and stream the data using Server-Sent Events (SSE):

curl https://api.litebase.io/v4/stream/starwars \
  -H "Authorization: Bearer $LITE_API_KEY"

You'll see:

data: Help me Obi-Wan Kenobi. You’re my only hope.

New events will continue streaming as they’re published.

3. Append in real time

Let’s have some fun: stream ASCII Star Wars into Litebase.

nc towel.blinkenlights.nl 23 | while IFS= read -r line; do
  curl -s -X POST https://api.litebase.io/v4/stream/starwars \
    -H "Authorization: Bearer $LITE_API_KEY" \
    -H "Content-Type: text/plain" \
    --data "$line" > /dev/null
done

Your subscriber terminal will come to life.

4. Replay past events

You can replay events from a specific transaction:

curl "https://api.litebase.io/v4/stream/starwars/events?fromTx=0" \
  -H "Authorization: Bearer $LITE_API_KEY"

Or from a specific timestamp:

curl "https://api.litebase.io/v4/stream/starwars/events?fromTime=2024-01-01T00:00:00Z" \
  -H "Authorization: Bearer $LITE_API_KEY"

Use ?follow=true to replay and continue live streaming:

curl "https://api.litebase.io/v4/stream/starwars?fromTx=0&follow=true" \
  -H "Authorization: Bearer $LITE_API_KEY"

Next steps