To stream live Polymarket trades in Python, pip install polyflux-client and iterate Client(api_key).trades() — or open a raw WebSocket to wss://stream.polyflux.io/polymarket/<your_key>. Both are shown below; both deliver every trade the millisecond it happens.
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.
Updated: this guide now leads with
polyflux-client, the official Python library. The raw WebSocket path still works from any language and is kept below.
The fastest way: polyflux-client
pip install polyflux-client
import asyncio
from polyflux import Client
async def main():
client = Client("YOUR_API_KEY")
async for trade in client.trades():
print(trade.wallet_address, trade.size, trade.price)
asyncio.run(main())
That’s a complete, production-shaped client: trades() yields only trade events (redeems, splits, and merges are filtered out for you), parsed into typed Trade objects, over a connection that reconnects automatically with backoff if it drops. A rejected key raises AuthError immediately instead of retrying forever.
Each Trade gives you the essentials as attributes — plus a few conveniences:
asset_id— the outcome token traded (use it for market lookups and order placement)wallet_address— who is tradingsize— position sizeprice— the odds they’re taking (0.00–1.00)side—buyorsell, with anis_buyshortcuttimestamp— millisecond precision, with.timefor a UTC datetime.notional—size × price, the trade’s USDC value.raw— the full original message, always
The
timestampis the point of the whole thing: you’re seeing this before the chain does. That’s your latency edge.
The library’s MarketCatalog — which turns each asset_id into a market you can name — gets a full guide of its own.
The raw WebSocket: five lines, any language
Under the hood the feed is a standard WebSocket — no SDK required, which is why it works from Node.js, Rust, Go, or a browser just as well. The raw Python client:
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())
Messages arrive as JSON: {"type": "events", "events": [ {...}, ... ]}. Going raw, you filter to trades yourself — the feed also carries redeems, splits, and merges:
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"])
This is exactly what client.trades() does for you — plus reconnection. Use raw when you want zero abstraction or a non-Python language; use the library when the stream feeds something that has to keep running.
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 (full tutorial)
- Position tracking — keep any wallet’s holdings current in real time
- 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 either snippet above, and you’re reading the mempool in under a minute.