Skip to main content

WebSocket Streaming

Connect to the WebSocket for real-time Polymarket trade data.

Connection

wss://ws.gimme.fast/ws
With compression (~60% bandwidth savings):
wss://ws.gimme.fast/ws?compress=zlib
On connect, you’ll receive:
{"type": "connected", "version": "0.1.0"}

Subscribe to Channels

All trades

{"action": "subscribe", "channel": {"type": "trades"}}

Trades for a specific token

{"action": "subscribe", "channel": {"type": "tokentrades", "token_id": "21742633143463..."}}

Market resolutions

{"action": "subscribe", "channel": {"type": "resolutions"}}

Unsubscribe

{"action": "unsubscribe", "channel": {"type": "trades"}}

Events

Trade event

{
  "type": "trade",
  "data": {
    "id": "uuid",
    "tx_hash": "0x...",
    "block_number": 12345678,
    "order_hash": "0x...",
    "maker": "0x...",
    "taker": "0x...",
    "token_id": "21742633143463...",
    "side": "BUY",
    "price": "0.72",
    "size": "500.00",
    "fee": "0.50",
    "neg_risk": true
  }
}

Resolution event

{
  "type": "resolution",
  "data": {
    "condition_id": "0x...",
    "payout_numerators": [1, 0]
  }
}

Compression

Add ?compress=zlib to the connection URL. When enabled:
  • All outbound messages are sent as binary frames compressed with deflate (zlib raw)
  • Decompress with any standard zlib/inflate implementation
  • Saves ~60% bandwidth — recommended for production
import WebSocket from "ws";
import { inflateRawSync } from "zlib";

const ws = new WebSocket("wss://ws.gimme.fast/ws?compress=zlib");

ws.on("message", (data, isBinary) => {
  const text = isBinary
    ? inflateRawSync(data).toString()
    : data.toString();
  const msg = JSON.parse(text);
  console.log(msg);
});

Ping / Pong

Send a ping to keep the connection alive:
{"action": "ping"}
Response:
{"type": "pong"}

Reconnection

If the connection drops, reconnect with exponential backoff:
  1. Wait 1 second, reconnect
  2. If it fails, wait 2 seconds
  3. Double the wait each time, up to 60 seconds max
  4. On success, re-subscribe to your channels

Best Practices

  • Use compression in production
  • Subscribe only to channels you need
  • Implement reconnection with backoff
  • Send pings every 30 seconds to detect dead connections
  • Process messages asynchronously to avoid blocking the receive loop