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.
Beyond trades: flows & resolutions
The feed carries more than trades. Each event has an event_type; typed
iterators give you just the ones you want:
# Money flows — the corrected, tx-level feed. Each event is a deposit (money in)
# or withdrawal (money out) of a Polymarket wallet, typed by where it went:
# external — real money crossing the Polymarket boundary (changes balances)
# p2p — to/from another PM wallet (surfaces as two events: the sender's
# withdrawal and the recipient's deposit)
# unidentified — counterparty we could not positively classify
async for f in client.money_flows():
print(f.op, f.type, f.amount, f.token, f.wallet_address, "cp:", f.counterparty)
# or client.deposits_v2() / client.withdrawals() for one direction.
#
# The legacy client.transfers()/deposits()/p2p_transfers() -> Transfer are
# DEPRECATED: they mislabel trade settlements as p2p and omit withdrawals.
# Prefer money_flows().
# UMA oracle resolutions — how every market ultimately settles.
async for r in client.resolutions(): # propose / dispute / settle
if r.is_dispute: # rare: a proposed answer was challenged
print("DISPUTED:", r.title, "by", r.disputer)
MoneyFlow— the corrected flow:op(deposit/withdrawal) xtype(external/p2p/unidentified),wallet_address,counterparty,amount,token,direction, plus.is_deposit/.is_withdrawal/.is_external/.is_p2p.Transfer(deprecated — useMoneyFlow) —event_type(deposit/p2p_transfer),from_address,to_address,amount(USD),token(USDC/USDC.e/USDT/pUSD),tier,pm_link_reason, plus.is_deposit/.is_p2p/.is_confirmed.Resolution—event_type(propose/dispute/settle),proposer,disputer,outcome(YES/NO/50-50),market_id,ancillary_hash,proposed_price,resolved_price, plus.title,.market_key, and.is_propose/.is_dispute/.is_settle. Group by.market_keyto follow a market across oracle resets — it's stable wheremarket_idisn't.
To watch several event types over a single connection, loop client.events()
and build the model per event_type (see the example below). The dedicated
iterators each open their own connection, so use one per process.
Examples
examples/quickstart.py— stream tradesexamples/whale_alert.py— alert on large trades, named by marketexamples/catalog_lookup.py— market-catalog projectionsexamples/resolutions_and_flows.py— deposits, p2p transfers & UMA resolutions
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
Metadata
Release files for polyflux-client 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polyflux_client-0.3.0.tar.gz | 20.5 kB | Without provenance | Details for polyflux_client-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polyflux_client-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for polyflux_client-0.3.0-py3-none-any.whl |
Total release size: 39.5 kB
Release files / polyflux_client-0.3.0.tar.gz
| Download URL | polyflux_client-0.3.0.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9151065ecd2adf0641faee94adeca1e7f67df1e6ba3f9e2323b2cd171134698
|
|
BLAKE2b-256 checksum How to use checksums |
8ff45898fff6d030584436da3d68960b9b653535b376fda02f082071913676da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / polyflux_client-0.3.0-py3-none-any.whl
| Download URL | polyflux_client-0.3.0-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b36a4914fad96924669165a91c12d28d97a7c5a5f341f6d381488140d7b9cd7
|
|
BLAKE2b-256 checksum How to use checksums |
9545ee2d125560b247afe613a7cd177f7df4fe59759c498c8dfdc461119ce474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for polyflux-client 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.