To stream live Polymarket trades in Python, connect a WebSocket to wss://stream.polyflux.io/polymarket/<your_key> and read each JSON message as it arrives. A full working client is five lines, shown below.
Most Polymarket data sources show you trades after they’ve settled on-chain — seconds late. If you’re building a bot, copy-trading whales, or hunting for an edge, those seconds are the whole game. This guide shows you how to stream every trade from the mempool, the millisecond it happens.
The five-line client
Once you have an API key, connecting is trivial. Open a standard WebSocket and read the feed:
import asyncio, json, websockets
URL = "wss://stream.polyflux.io/polymarket/<your_key>"
async def main():
async with websockets.connect(URL) as ws:
async for raw in ws:
t = json.loads(raw)
print(t["wallet_address"], t["size"], t["price"])
asyncio.run(main())
That’s it. Every trade — buy or sell, taker or maker — arrives as a JSON message before it’s confirmed on-chain.
What each message looks like
Each event carries the fields you need to act on a trade:
wallet_address— who is tradingsize— position sizeprice— the odds they’re taking (0.00–1.00)operation_type—buyorsellevent_type—trade, or redeems / splits / merges you can skiptimestamp— millisecond precision
The
timestampis the point of the whole thing: you’re seeing this before the chain does. That’s your latency edge.
Filtering to just the trades
The feed includes non-trade events (redeems, splits, merges). Skip them:
async for raw in ws:
msg = json.loads(raw)
if msg.get("type") != "events":
continue
for t in msg["events"]:
if t.get("event_type") != "trade":
continue
# act on the trade here
print(t["wallet_address"], t["size"], t["price"])
Where to go from here
From this stream you can build:
- Whale alerts — fire when
sizecrosses a threshold - Copy-trading — mirror a set of known-sharp wallets
- Signals — aggregate flow into a real-time sentiment view
The feed is the same one that powers the Polyflux live dashboard. Grab a key, paste the snippet above, and you’re reading the mempool in under a minute.