Guide July 22, 2026 · updated July 26, 2026

How to stream live Polymarket trades in Python

Connect to the Polymarket mempool feed and read every trade the millisecond it happens — with the polyflux-client library or a raw WebSocket.

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 trading
  • size — position size
  • price — the odds they’re taking (0.00–1.00)
  • sidebuy or sell, with an is_buy shortcut
  • timestamp — millisecond precision, with .time for a UTC datetime
  • .notionalsize × price, the trade’s USDC value
  • .raw — the full original message, always

The timestamp is 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:

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.

Frequently asked questions

Is there a real-time Polymarket API?
Yes. Polyflux exposes a WebSocket endpoint (wss://stream.polyflux.io/polymarket/<key>) that streams every Polymarket trade as JSON in real time, before it confirms on-chain. The polyflux-client Python library wraps it with typed trades and auto-reconnection.
What is the easiest way to stream Polymarket trades in Python?
pip install polyflux-client, then iterate Client(api_key).trades() in an async for loop. The library handles connection, parsing, filtering to trade events, and automatic reconnection.
What language can I use to stream Polymarket data?
Any language with a WebSocket client works — Python, Node.js, Rust, Go, or even a browser. Python additionally has the official polyflux-client library on PyPI.
What fields does each Polymarket trade message contain?
asset_id (the outcome token traded), wallet_address (who traded), size (position size), price (odds, 0.00–1.00), operation_type (buy or sell), event_type (trade, redeem, split, merge), and a millisecond timestamp.
How much faster is mempool data than the on-chain data?
Mempool trades typically appear about 3 seconds before they are confirmed into a block, which is the window traders use to act ahead of slower participants.
← All articles