polyflux
Official Python client for Polyflux — stream real-time Polymarket trades from the mempool over WebSocket.
See every Polymarket trade the millisecond it happens — ~3 seconds before it confirms on-chain. Build trading bots, whale alerts, and real-time signals in a few lines of Python.
You need a Polyflux API key to stream. Get one at polyflux.io → (free trial).
Install
pip install polyflux-client
Then import polyflux in your code.
Quickstart
import asyncio
from polyflux import Client
async def main():
client = Client("YOUR_API_KEY") # get one at https://polyflux.io
async for trade in client.trades():
print(trade.side, trade.size, trade.price, trade.wallet_address)
asyncio.run(main())
Each Trade gives you asset_id, wallet_address, size, price, side
(buy/sell), timestamp, plus helpers like .notional (USDC value) and
.time (UTC datetime). The full raw message is always on .raw.
The client handles connection, parsing, and automatic reconnection — just
async for over .trades() and let it run.
Resolve markets
The feed identifies markets by asset_id (a clob token id). Use MarketCatalog
to turn that into a human-readable market:
from polyflux import Client, MarketCatalog
catalog = MarketCatalog(market_fields=["question"])
await catalog.start() # caches the active-market set under ./data
async for trade in client.trades():
record = catalog.get(trade.asset_id)
if record:
print(record["market"]["question"], trade.size, trade.price)
MarketCatalog keeps an O(1) asset_id → market map with a configurable memory
footprint, refreshes in the background, and can fetch unknown ids on demand. See
examples/whale_alert.py for a full bot.
Examples
examples/quickstart.py— stream tradesexamples/whale_alert.py— alert on large trades, named by marketexamples/catalog_lookup.py— market-catalog projections
POLYFLUX_API_KEY=your_key python examples/quickstart.py
Links
- Get an API key: https://polyflux.io/auth
- Guides: https://polyflux.io/blog
- Live feed / product: https://polyflux.io
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polyflux_client-0.1.0.tar.gz.
File metadata
- Download URL: polyflux_client-0.1.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
613ad67d0476371fa2f259ca6d8112362252328e6753e0e4968bcf3b7ac24c65
|
|
| MD5 |
2dc84c8702d09177dea85fb4628a1ef2
|
|
| BLAKE2b-256 |
7b3f1d40b3b2752168b22ee86ef6f1cfbc6ee3e384398886d6b9f2ac3148a951
|
File details
Details for the file polyflux_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: polyflux_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70cdcb82752f734e6f3b653af956d92168175444044469b981afbc18ca45fb84
|
|
| MD5 |
5c90d7edf64995877a0d37e7f97b3cee
|
|
| BLAKE2b-256 |
e66a468443169603776546960cef0e2616cb59d0144f64e14362f189a7505b8d
|