POST /v1/poll
Receive events over HTTP long-polling, with stateless cursors and state versions, where WebSockets are blocked.
POST https://realtime.folkways.net/v1/poll
Authorization: Bearer <token>
Content-Type: application/octet-stream
<one client packet with one Poll frame>A stateless read that can wait for new events. The server keeps nothing between polls: each request sends the positions to read from, and the response carries the events after them.
Build a client in another language has a complete, tested Python client that encodes polls, decodes replies and runs this loop.
The Poll frame
| Field | Default | Meaning |
|---|---|---|
topics | required | 1 to 256 Subscribe entries, with start, cursor, on_gap and types as on a WebSocket |
max_events | 100 | Events across all topics, at most 1,000 |
wait_ms | How long to wait when nothing is available yet, at most 25,000. 0 returns at once |
Response
200 with application/octet-stream: server packets, each prefixed by its little-endian u32 length. All frames
carry the poll's corr:
- for each topic: an optional
Gap, thenSubAck, thenDeliverframes, orSnapshotframes for KV and signals; - finally
PollEnd { timed_out, more }.
more: true means more events are waiting: poll again at once.
The next poll
- For stream events, set each topic's
start: Afterandcursorto the last event you received. - For KV and signals in a one-type topic, a poll with a cursor from the same epoch returns only keys changed after it, including deletions; without one, a snapshot.
- For KV and signals in a topic with several types, send
state_afterset to the lastSubAck.state_latest. You get only the changes after it; without it, a snapshot.state_latestcomes in every answer, even an empty one, so the next poll can wait.
Signals between polls are best effort.
Draining
When the server starts draining, a waiting poll returns at once with PollEnd { timed_out: true }. The next request
to that server gets 503 with a Close { Draining, retry_after_ms } frame; retry after the delay.
Errors
Per-topic failures are OpError frames inside a 200. An authentication or packet-level failure returns the code's
HTTP status with a Close frame. CORS allows any origin, as for /v1/publish.
Running a poll loop
- One poll at a time. Send the next poll when the previous one ends; overlapping polls receive the same events twice.
- Match replies by
topic_id, learned from each topic'sSubAck. A topic the server refuses outright is reported withtopic_id0, ahead of the other topics' replies, so learn each new topic's id with a one-topic poll (wait_ms: 0) first. - Refresh the token between polls, a minute before it expires. A poll refused with
AuthExpiredcan be sent again with a new token. - Retry
RateLimited,Unavailable,DrainingandTimeoutafterretry_after_ms, with backoff and jitter. Don't retryAuthInvalid,Forbidden,SuspendedorAuthRevoked.