Realtime

Broadcast channels over WebSockets: every message published to a channel reaches every connection subscribed to it.

GET  /realtime/v1/ws?channel={name}&token={jwt}
POST /realtime/v1/broadcast
This is an in-house, native protocol — one WebSocket per channel, with a small JSON frame format described below. It is built and served entirely by Kethosbase; there is no third-party realtime service behind it. You can speak it directly with the browser WebSocket API, or use the JavaScript SDK's channel() helper, which wraps it.

Connecting

Open a WebSocket to your project with a channel name ([a-zA-Z0-9:_-], up to 128 chars) and any project JWT — the anon key, an end-user access token, or the service-role key:

const ws = new WebSocket(
  "wss://<ref>.kethosbase.com/realtime/v1/ws" +
  "?channel=room:42&token=" + anonKey
);

ws.onmessage = (e) => {
  const msg = JSON.parse(e.data);
  // { event: "broadcast", channel: "room:42", payload: { … } }
};

Publishing

Send a JSON frame on an open socket:

ws.send(JSON.stringify({
  event: "broadcast",
  channel: "room:42",
  payload: { kind: "chat", text: "hello" }
}));

Or publish over HTTP — handy from a backend:

curl -X POST "https://<ref>.kethosbase.com/realtime/v1/broadcast" \
  -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -d '{"channel": "room:42", "payload": {"kind": "ping"}}'

→ { "delivered": 5 }

Connection lifecycle and re-auth

The token is presented in the query string and validated at connect time: an invalid or expired token is rejected during the WebSocket handshake, and the channel prefix (db: vs a plain name) fixes what the connection may do. There is no in-band re-auth frame — the connection carries the identity it opened with.

Limits

LimitValue
Message size64 KiB
Connections per IP20
Connections per project50 (Starter) / 500 (Pro) / 2,000 (Business)
HTTP publishes per IP600 / minute

A connection that publishes too fast receives {"event": "rate_limited"} frames; over-limit connection attempts are rejected with 429.

Database change feeds

Channels named db:{table} are change feeds: instead of carrying what clients publish, they stream the table's inserts, updates, and deletes straight from the database.

const ws = new WebSocket(
  "wss://<ref>.kethosbase.com/realtime/v1/ws" +
  "?channel=db:todos&token=" + serviceRoleKey
);

ws.onmessage = (e) => {
  const { event, payload } = JSON.parse(e.data);
  // event: "change"
  // payload: { action: "insert", table: "todos",
  //            record: { id: 1, task: "ship it", done: false }, old: null }
};