Polymarket API: a live trade feed that gets 99% of fills within 2.4 seconds
Every Polymarket trade settles on Polygon. We built a feed that prints each fill, result and payout straight from the chain, timed it, and found the trap that makes a naive feed count every trade twice.

Every Polymarket trade settles on Polygon. Bitquery's API decodes those trades and streams them over a socket. We built a feed on that stream in one Python file. It prints every fill with its market, outcome, price and size. It also marks each market when it resolves, and prints each payout.
On 2 December 2026, we ran it for an hour on a small server in Singapore. A fill reached our code a median of 0.86 seconds after its Polygon block, and 99 in 100 arrived within 2.4 seconds. If you run a trading bot, an alert channel or a live odds page, that gap is the time you have to act.
- 0.86 s
- 3.1×
- 2.0×
- 75%
- 16 s
- 28%
What the Polymarket trade feed prints
The feed prints one line per trade, one per market result and one per payout. This is our terminal on 2 December, in two short excerpts from the same run:
Read a FILL line from left to right. Take the second FILL line. Its market, cut short in the image, is "Exact Score: Jeonbuk FC 3 - 3 Gamba Osaka?". A wallet bet against that score: it bought "No" at 98.7 cents a share. It bought 77.9 shares for $76.90 and filled two resting orders, the makers. lag is the time from the Polygon block to the moment the line reached us.
A RESOLVED line names the winning outcome. Here, seven markets on one Counter-Strike match settled in the same block, and two of them had no single winner. A PAYOUT line is winning shares cashed in for USDC. The first payouts on that match arrived six seconds after its result.
The code is on GitHub, bitquery/polymarket-trade-feed. Run it in four commands:
git clone https://github.com/bitquery/polymarket-trade-feed && cd polymarket-trade-feed
pip install -r requirements.txt
echo 'BITQUERY_TOKEN=your_access_token' > .env
python feed.py
To get an access token, sign up for Bitquery and create one under API access tokens, as the token guide shows. The free trial allows two streams at once, so start with python feed.py --no-payouts, which needs two.
How the feed works
Polymarket is a prediction market. Each market asks a question, such as "Bitcoin above 61,600 on December 2?", and sells shares in each answer. A share pays $1 if its answer wins and $0 if it loses, so its price, between 0 and 1, reads as the crowd's odds.
People trade those shares on an order book. When two orders match, the trade settles on Polygon, and the exchange contract emits one OrderFilled event for each order in the match. Bitquery decodes those events, ties each one to its market question and outcome, and serves them in three datasets, which Bitquery calls cubes:
| Cube | What it holds | What the feed does with it |
|---|---|---|
PredictionTrades | Every OrderFilled event, with market, outcome, shares and cash | Prints each trade once |
PredictionManagements | Markets created and markets resolved, with the winning outcome | Marks the market as resolved |
PredictionSettlements | Splits, merges and redemptions of outcome shares | Prints each payout |
The feed sends one query with all three cubes over wss://streaming.bitquery.io/graphql. Each cube counts as a separate stream for billing, which the cost section covers. The Polymarket API page lists the same three datasets, and the docs have a page for each: trades, market results and payouts.
Step 1: subscribe to fills, results and payouts
Open a socket with your token in the URL and the graphql-ws protocol, as the socket docs describe. Then send the query. This is the part for fills; queries.py holds all three cubes:
subscription PolymarketFeed {
EVM(network: matic) {
PredictionTrades(
where: {
TransactionStatus: {Success: true}
Trade: {Prediction: {Marketplace: {ProtocolName: {is: "polymarket"}}}}
}
) {
Block { Time Number }
Transaction { Hash To }
Log { Index SmartContract }
Trade {
OutcomeTrade {
Buyer Seller IsOutcomeBuy
Amount CollateralAmount CollateralAmountInUSD
Price Fee { AmountInUSD }
}
Prediction {
ConditionId
Question { Title }
Outcome { Label }
}
}
}
}
}
network: matic is Polygon. The ProtocolName filter drops other betting markets on Polygon. Transaction.To and Log.SmartContract look like extras, but step 2 needs both.
The connection takes a few lines of Python:
async with websockets.connect(f"wss://streaming.bitquery.io/graphql?token={token}",
subprotocols=["graphql-ws"], max_size=None) as ws:
await ws.send(json.dumps({"type": "connection_init"}))
await ws.send(json.dumps({"id": "1", "type": "start",
"payload": {"query": feed_subscription()}}))
while True:
raw = await asyncio.wait_for(ws.recv(), timeout=10)
received = time.time() # stamp first, parse later
queue.put_nowait((received, raw))
Each message holds every new row from one Polygon block. A separate task reads the queue and prints, so a slow terminal never delays the arrival time, which the lag is measured from.
Step 2: print each trade once
One trade comes back as several rows. When a taker's order crosses the book, it can fill many resting orders, called maker orders, at once. The exchange emits one OrderFilled event for each maker order and one more for the taker's order. All of them land in PredictionTrades.
On the taker's own row, the other side is a Polymarket contract. It is either the exchange that emitted the event, or a router contract that passed the trade to the exchange. The feed keeps that row and counts the others:
def is_taker(row):
o = row["Trade"]["OutcomeTrade"]
contracts = {row["Log"]["SmartContract"].lower(), row["Transaction"]["To"].lower()}
return o["Buyer"].lower() in contracts or o["Seller"].lower() in contracts
On 1 December, this rule found exactly one taker row in every trade of the day, more than a million of them. Checking the exchange contract alone is not enough. Most trades on exchange 0x862f…4e55 route through 0xe333…00aa, and the other side on their taker row is that router. The first trap below shows what happens if you skip this step.
On the taker's row, IsOutcomeBuy is the taker's direction: true means the taker bought the outcome named in Outcome.Label. The wallet that is not the contract is the taker.
Step 3: work out the price yourself
Price is null on the stream. In a 40-second capture on 2 December, every one of 952 streamed rows came back with Price: null. The same field is filled in the HTTP query.
Compute it from the two amounts instead. The price of an outcome share is the cash paid divided by the shares:
price = o["Price"] if o["Price"] is not None else float(o["CollateralAmount"]) / float(o["Amount"])
We checked the formula on every row of an HTTP sample, where Price is filled. It matched each one to the last decimal.
Step 4: mark results and payouts
When a market resolves, PredictionManagements returns a Resolved row with the winning outcome in Outcome.Label. The feed stores the result under the market's ConditionId, the on-chain ID of the question, and tags later fills on that market:
def on_resolution(self, m):
p = m["Management"]["Prediction"]
winner = p["Outcome"]["Label"] or "no single winner (split payout)"
self.resolved[p["Condition"]["Id"]] = winner
An empty label is a real result. The fourth trap below explains it.
Payouts come from PredictionSettlements rows whose EventType is Redemption. A holder redeems outcome shares after the result, and the contract pays $1 for each winning share. The stream query drops redemptions that pay nothing, on the server, with Amounts: {CollateralAmount: {gt: "0"}}.
Step 5: recover fills after a dropped socket
A socket can go quiet without closing. Bitquery sends keep-alive messages between data messages, so the feed treats 10 seconds of silence as a dead connection, as the reconnect guide suggests. It then opens a new socket.
Fills that settled while the socket was down never arrive on the new one. So the feed asks the HTTP API for every fill from the last block it printed, and skips the ones it already has:
query Backfill($since: String!, $limit: Int!) {
EVM(network: matic) {
PredictionTrades(
limit: {count: $limit}
orderBy: [{ascending: Block_Number}, {ascending: Log_Index}]
where: {
TransactionStatus: {Success: true}
Trade: {Prediction: {Marketplace: {ProtocolName: {is: "polymarket"}}}}
Block: {Number: {ge: $since}}
}
) { ...same fields as the subscription... }
}
}
We tested it by cutting the socket for eight seconds. The backfill recovered 85 fills, with no duplicates and no missing blocks.
Step 6: measure the lag
The feed writes each fill's lag to a CSV file with --log. Lag is the time the message arrived minus the time of the Polygon block that holds the fill. latency.py reads the file:
python feed.py --log data/fills.csv --minutes 60
python latency.py data/fills.csv
How fast is the Polymarket stream?
The feed timed every fill for an hour on 2 December, from a server in Singapore. The median fill, the one in the middle when you line up all the lags, arrived 0.86 seconds after its block. Seven in ten arrived within a second, and 96% within a second and a half. The table below has the rest.
| Measure | Median | 90% within | 99% within | Slowest |
|---|---|---|---|---|
| Stream, per fill | 0.86 s | 1.26 s | 2.41 s | 16.43 s |
| Stream, first fill of each block | 0.76 s | 1.16 s | ||
| HTTP polling once a second, per new block | 2.62 s | 3.15 s |
For comparison, poll_compare.py asked the HTTP API once a second for the newest fill, for the first five minutes of the same run. It saw each new block a median of 2.62 seconds after the block was made. A poller also needs a request every second, and each request costs API points.
The median held steady all hour, between 0.63 and 1.03 seconds in every minute. The slow tail came from a few late blocks. Of the 18 blocks that arrived more than 3 seconds late, 12 landed 20 to 35 seconds after a five-minute mark on the clock: 09:20, 09:25, 09:30 and so on. Polymarket's five-minute bitcoin and ether markets open and close on those marks. The slowest were three blocks at 09:37 UTC, 12 to 16 seconds late.
The socket stayed open the whole time, so the feed's silence check never fired, and every fill still arrived. Plan for late blocks like these. A bot that acts on a fill should compare the block time with the clock, and skip a signal that is already stale.
What breaks: four traps in Polymarket trade data
Four traps gave our feed wrong numbers on live data in late 2026. Each one below comes with the rows that show it.
1. Every trade shows up twice
PredictionTrades returns one row for each order in a match, so the taker's row and the maker rows describe the same shares. Here is one trade from 2 December, an NBA game:
Sum every row, and you count those shares twice. On 1 December, the rows held exactly twice the shares that traded:
In dollars, the two sides differ, so pick one and say which. Bitquery's Polymarket dataset in the Data Store counts volume from the maker rows. For a trade tape, print the taker's row, as the feed does.
2. The two sides often hold opposite outcomes
The trade in the figure above created new shares. The taker bought Pistons at 69 cents while the resting orders bought Grizzlies at 31 cents. Together they paid $1 a pair, and the exchange minted one share of each team for each dollar.
In our hour of fills, 75% of trades matched opposite outcomes this way. Build a Pistons price chart from every row, and the line jumps between 0.69 and 0.31 on the same trade. Chart one outcome's rows only, or turn the other outcome's price around with 1 − price. That works for markets with two outcomes.
3. One exchange sends no market ID
On 1 December, Polymarket fills came from three exchange contracts. On one of them, 0x862f…4e55, the Question.MarketId field is empty. That exchange carried about a fifth of the rows that day, and nearly two thirds of the rows in our hour a day later.
Code that groups trades by MarketId puts all of them in one bucket with no name. Key markets on ConditionId instead. All three cubes carry it: Trade.Prediction.ConditionId, Management.Prediction.Condition.Id and Settlement.Prediction.ConditionId hold the same value for the same market.
4. Payouts of $0 and results with no winner
On 1 December 2026, 28% of payout events paid nothing. A holder can redeem the losing side of a market, and the contract records a redemption of $0. A payout alert that prints every redemption is mostly noise.
The same day, about one resolved market in a hundred returned an empty winning outcome. We read the on-chain result of each one. All of them paid both sides half: their payoutNumerators were [1, 1]. Most were voided sports markets and over/under lines. Treat an empty label as a split result. The market has resolved.
Polymarket API pricing: streams, minutes and GB
Bitquery bills a stream on three meters: the number of streams, stream-minutes and the data pushed over the socket. Each cube in a stream query counts as one stream, so the full feed uses three.
We counted the data with feed.py itself, which adds up the size of every message it receives. Over the hour, the full feed received 116.7 MB, or 1.95 MB a minute. At that rate, the Pro plan's 5 GB lasts under two days. Traffic rises and falls with Polymarket's activity, so measure your own feed before you pick a plan.
| Run | Streams | Stream-minutes | Stream data | Plan that covers it |
|---|---|---|---|---|
Try it, --no-payouts | 2 | 16 for 8 minutes | under 0.02 GB | Free trial: 17 stream-minutes, 0.2 GB |
| Full feed, all month | 3 | 129,600 | about 84.0 GB | Scale, $299 a month: 2 million minutes and 50 GB, plus seven 5 GB packs at $50 each |
| Full feed on Pro | 3 | 129,600, over Pro's 100,000 | 5 GB lasts 1.8 days | Pro, $99 a month, needs add-ons that cost more than Scale |
We read these prices on the pricing page on 2 December 2026. A stream-minute is one stream connected for any part of a minute. The backfill and the polling script use API points instead. Each HTTP query costs points, and the trial includes 1,000.
For a feed that runs all day, the stream data runs out first. Three things cut it. Drop fields you do not print. Filter on the server, as the feed does for $0 payouts. Or subscribe to the markets you follow, with a ConditionId filter. For an unmetered firehose, Bitquery sells Kafka streams on Enterprise plans.
Limits
- Polygon only. The feed reads Polygon and nothing else. Bitquery's Polygon API covers the rest of the chain.
- Fills only, no order book. The feed sees trades after they settle. It does not see resting orders, cancelled orders or the book's depth. Polymarket's own order book API serves those.
- About four days of history on the HTTP API. On 2 December, the oldest fill in the real-time dataset was from 28 November. The backfill is for dropped sockets. It cannot reach back months.
- Older history is an add-on. The Polymarket history add-on starts on 1 September 2025 and costs $150 a month. The Data Store sells the same history as files, below.
- No order placement. The code reads data only. It places no orders and holds no keys.
- Lag depends on your network. We ran the feed on one server in Singapore. From another region, the network path to Bitquery's endpoint changes, and so does the lag.
How we tested
- Latency. One run of
feed.pyfor 60 minutes on 2 December, 09:16 to 10:16 UTC, on the live endpointwss://streaming.bitquery.io/graphql. It ran on a small AWS server (t3.micro) in Singapore. Lag is arrival time minus block time. The server synced its clock to Amazon's time service, and the clock sat within a microsecond of it when the run began. Percentiles are exact, by nearest rank. - Polling.
poll_compare.py, one request a second for the first five minutes of the same run, on the same server. - Completeness. We read every fill in the run's blocks again over HTTP later. The HTTP API returned 51,003 trades in those blocks. The stream had delivered every one of them, with none missing and none extra.
- Spot check. For the 10 busiest markets of the run, nine of them five-minute bitcoin markets, we pulled every trade from Polymarket's own Data API and matched transaction hashes. Polymarket listed all 16,225 of our transactions and no others, and every one matched on the taker's price and size.
- Day figures. Counts and sums for 1 December 2026, 00:00 to 24:00 UTC, from the HTTP API with exact unique counts.
- Split results. We read the
ConditionResolutionevent of each of the 211 markets with an empty winning outcome.
We used AI tools to write and run the test queries, and we checked each figure against the live API. The data behind every number and chart is saved with the article.
Polymarket history as files
The API keeps about four days of fills. For a backtest or a dashboard with months of history, use the Polymarket dataset in the Data Store. It has every fill, payout and market result since 1 September 2025 as Parquet files, with a free sample of each table. The latest month costs $400 and the full history $4,000.
FAQ
Is the Polymarket API free?
Polymarket's own APIs are free to read. The Bitquery API, which this guide uses, has a free trial for a week with two streams, enough to run this feed for a few minutes. Streaming after that needs the Pro plan at $99 a month, as read on 2 December 2026.
Does Polymarket have a WebSocket for trades?
Yes. Polymarket's own socket streams order book updates. The Bitquery stream sends trades after they settle on Polygon, with the market question, outcome, price, size and fee, plus market results and payouts. In our test, a fill reached our code a median of 0.86 seconds after its Polygon block, and 99% within 2.4 seconds.
How do I get Polymarket trade data in Python?
Open a socket to wss://streaming.bitquery.io/graphql with the graphql-ws protocol and subscribe to PredictionTrades on EVM(network: matic), filtered to Polymarket. Keep the taker's row of each trade, and compute the price as CollateralAmount / Amount. The repo bitquery/polymarket-trade-feed has the full code.
Why does my Polymarket volume look twice as high?
You are summing both sides of each trade. Every match returns a row for the taker and a row for each maker order, and they hold the same shares. On 1 December 2026, summing every row gave exactly twice the shares that traded.
How do I get Polymarket historical data?
The Bitquery HTTP API keeps about four days of fills in its real-time dataset. For older data, the Polymarket history add-on starts on 1 September 2025, and the Data Store sells the same history as Parquet files.
Related reading
- Bitquery Polymarket API: the product behind this feed
- Prediction market API in the docs
- WebSocket streams and Bitquery MCP server
- How much of Polymarket is bots?
- Polymarket built a casino. Almost all of the players have left.
- One Polymarket disputer is 80 for 80: who decides disputes
- How much of Polygon is Polymarket? We counted every transaction
Subscribe to our newsletter
Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.