Polyrankdocs

Real-time (WebSocket)

Live fills, mid-price moves, and resolutions over wss://ws.polyrank.app.

Handshake

Mint a short-lived token (requires a session — sign in at polyrank.app):

curl -s -X POST https://api.polyrank.app/v1/auth/ws-token \
  -H "Cookie: __Secure-polyrank_sid=…"

Returns a JWT valid for 5 minutes — it authorizes the handshake, not the connection lifetime.

Connect with the token:

wss://ws.polyrank.app/?t=<JWT>

Subscribe:

{ "action": "subscribe", "topics": ["trader:0xabc…", "market:0xdef…:book"] }

Topics

TopicAuthStream
trader:{proxy}sessionPublic fills for one wallet — powers the Follow feed
market:{conditionId}:tradespublicTrade prints for a market
market:{conditionId}:bookpublicLive mid + best bid/ask (first to shed under backpressure)
market:{conditionId}:resolvedpublicResolution events
user:{userId}:notifysessionYour notification stream

Limits: 100 topics per connection, of which at most 50 trader: topics.

Client best practices

Mirror what the Polyrank web app does:

  • Send an app-layer ping every 10 seconds.
  • When the JWT has less than 60s of validity left, mint a fresh token and reconnect silently; close the old socket before opening the new one.
  • Treat 401 and 403 as terminal — re-auth or stop; do not hot-loop reconnects.
  • Diff your subscription set on change (unsubscribe removed topics) instead of reconnecting.

Event shape

Events are JSON with a topic field plus the payload (fill, book update, or resolution). Fills carry wallet, market, side, price, and notional — enough to drive a copy-feed UI without further lookups.

On this page