ws
library, but the protocol is plain JSON over a standard WebSocket, so you can
use any WebSocket client.
Prerequisites
- Your ParlayX API key — the same signed Ed25519 key you use for REST. See Authentication.
- One or more
MarketStreamvalues for the markets you want. See identifying markets.
1. Connect and authenticate
Sign the handshake with your private key and put the credentials on the query string of:401
before the connection opens. A 503 means the gateway is at capacity —
reconnect, and you’ll land on fresh capacity. A 429 means your account is at
its connection limit — close a
connection you no longer need instead of retrying.
2. Receive welcome
Immediately after the upgrade succeeds, the server sends a welcome frame:
connectionId — quote it in any support request so we can find your
session in our logs. The limits tell you how many subscriptions this
connection accepts and how long it will live before the server closes it for a
scheduled reconnect.
3. Subscribe
Send asubscribe frame listing the markets you want. The only required
fields are type and markets; channels defaults to ["book"].
subscribed ack
or an error (for example, UNKNOWN_MARKET) — one reply per market, so a
single bad entry never sinks the rest of the batch.
subscriptionId to whatever local state you keep for
that market — every subsequent frame for this subscription is keyed by that id,
and it’s also the handle you pass to unsubscribe.
snapshotPending: true tells you a snapshot is on its way.
4. Apply the stream
A book subscription delivers asnapshot first, then delta frames:
snapshot replaces your book; delta
mutates it. Because of the sequencing contract,
your apply loop needs no gap-handling logic of its own — if we ever could not
send a contiguous delta, we send a fresh snapshot instead.
Optional: the trade tape
To also receive each fill on a market as it executes, subscribe with thetrade channel (each (market, channel) pair is its own subscription, with
its own subscriptionId):
snapshotPending: false on the ack), and frames flow from the moment you
subscribe — earlier fills are not replayed. See the
trade frame reference for the full semantics.
The trade channel is available on Polymarket and Kalshi; Limitless publishes no
public trade feed, so a trade subscribe there is rejected with
UNSUPPORTED_CHANNEL.
5. Keep the connection healthy
- The server sends WebSocket pings every 30 seconds; your client library
answers them automatically. You can also send an application-level
pingand get apongback. - Watch for
goodbyeframes and socket closes, and reconnect. Connections are closed at theconnectionTtlSecondslifetime fromwelcome, so schedule a proactive reconnect before then. - On a
statusframe withstate: "resyncing", drop that subscription’s local book and trust the nextsnapshot. See reconnect & resync handling.