Keep market data current with Polymarket’s real-time feeds.
Use Polymarket’s real-time feeds to react as market conditions and related data
change. They keep the public market data your application depends on current
without repeated polling. For authenticated order and trade updates, see
Real-Time Order Updates.
Market Stream
Use the market stream to keep your application in sync with changes to a
market’s order book and trading state.
TypeScript
Python
API
The unified SDK uses assetId for an outcome’s trading identifier: a token
ID for a CTF market or a position ID for a Polymarket Protocol V2 market.
Use the identifier exposed for that outcome.Given a PublicClient or SecureClient, subscribe to the market topic with one or
more outcome IDs:
const assetId = "<asset_id>";const stream = await client.subscribe([ { topic: "market", assetIds: [assetId], },]);for await (const event of stream) { switch (event.type) { case "book": // event: MarketBookEvent break; case "price_change": // event: MarketPriceChangeEvent break; case "last_trade_price": // event: MarketLastTradePriceEvent break; case "tick_size_change": // event: MarketTickSizeChangeEvent break; }}
The unified SDK uses asset_id for an outcome’s trading identifier: a token
ID for a CTF market or a position ID for a Polymarket Protocol V2 market.
Use the identifier exposed for that outcome.Given an AsyncPublicClient or AsyncSecureClient, subscribe to the market
stream with a MarketSpec containing one or more outcome IDs:
from polymarket.streams import MarketSpecasset_id = "<asset_id>"async with await client.subscribe( MarketSpec(asset_ids=[asset_id]),) as stream: async for event in stream: if event.type == "book": ... # event: MarketBookEvent elif event.type == "price_change": ... # event: MarketPriceChangeEvent elif event.type == "last_trade_price": ... # event: MarketLastTradePriceEvent elif event.type == "tick_size_change": ... # event: MarketTickSizeChangeEvent
These frames update only the outcome set for the current market-stream
connection."initial_dump": false only skips snapshots on the opening market frame. A
subsequent subscribe frame ignores it and always sends a book snapshot for
each outcome ID it adds.
Sports Stream
Use the sports stream to keep live game information current alongside sports
markets. Updates arrive when a game goes live, its score or period changes, or
it ends. NFL and CFB updates can also reflect possession changes.
Sports data is provided for informational purposes only. It may be delayed,
contain errors, or omit recent events. Polymarket does not provide trading or
investment advice, and this data should not be used as the basis for a trading
decision.
TypeScript
Python
API
Given a PublicClient or SecureClient, subscribe to the sports topic to receive
every game update:
score is a combined "<home>-<away>" string, not separate home and away
fields.
Given an AsyncPublicClient or AsyncSecureClient, subscribe with a
SportsSpec to receive every game update:
from polymarket.streams import SportsSpecasync with await client.subscribe(SportsSpec()) as stream: async for event in stream: ... # event: SportsEvent
score is a combined "<home>-<away>" string, not separate home and away
fields.
Connect to the sports WebSocket:
wss://sports-api.polymarket.com/ws
The sports WebSocket uses an application-level heartbeat. The server sends the
text frame ping every 5 seconds; reply with pong within 10 seconds or the
server closes the connection.
Once connected, the server starts streaming every game update. No
subscription frame is required.
If your chosen provider doesn’t serve a symbol, the subscription falls back to that symbol’s default provider. See Supported Symbols for feed availability and default providers. Check the source reported with spot prices, including after reconnecting.
Chainlink Feeds
Use Chainlink prices to inform trading decisions in markets that reference those prices.To use Chainlink feeds through PolyBolt, create Data Streams credentials in the Chainlink app. Keep a note of the value labeled Username. You’ll need it wherever a Chainlink API key is required. Use of Chainlink data is subject to the Chainlink Data Streams Terms of Service.
Treat your Chainlink API key as sensitive. Store it on trusted infrastructure
and keep it out of client-side code and public configuration.
If you’re a builder displaying Chainlink prices to end users, connect to PolyBolt from your backend using your Chainlink API key. Deliver prices only to signed-in users of your own app over an authenticated WebSocket.
Crypto Prices
Stream crypto reference prices in USD to keep prices current alongside related markets. Each new subscription starts with a snapshot of up to two minutes of recent prices, followed by live updates.
Read the initial snapshot and live updates from the stream.
try { for await (const event of stream) { switch (event.type) { case "subscribe": { const history = event.payload.data; // Use the initial snapshot to populate your chart. break; } case "update": { const price = event.payload.value; // Decimal string, for example "78794.15450441". const observedAt = event.payload.timestamp; // Update your chart with the new price and its timestamp. break; } default: continue; } }} finally { await stream.close();}
The subscribe event provides the initial snapshot in payload.data. Each update event provides the new price as a decimal string in payload.value. Timestamps are numbers representing milliseconds since the Unix epoch.
Read the initial snapshot and live updates from the stream.
async with stream: async for event in stream: match event.type: case "subscribe": history = event.payload.data # Use the initial snapshot to populate your chart. case "update": # For example, Decimal("78794.15450441"). price = event.payload.value observed_at = event.payload.timestamp # Update your chart with the new price and its timestamp. case _: continue
The subscribe event provides the initial snapshot in payload.data. Each update event provides the new price as a Decimal in payload.value. Timestamps are UTC datetime objects.
Open a WebSocket connection to wss://ws-live-v2.polymarket.com/ws.
Send your CLOB API credentials in the
first frame. Choose the auth frame for the provider you plan to use.
Stream reference prices for stocks, ETFs, forex pairs, precious metals, and commodities. Each new subscription starts with a snapshot of recent prices, typically covering up to two minutes, followed by live updates.
Read the initial snapshot and live updates from the stream.
try { for await (const event of stream) { switch (event.type) { case "subscribe": { const history = event.payload.data; // Use the initial snapshot to populate your chart. break; } case "update": { const price = event.payload.value; // Decimal string, for example "316.1". const observedAt = event.payload.timestamp; // Update your chart with the new price and its timestamp. break; } default: continue; } }} finally { await stream.close();}
The subscribe event provides the initial snapshot in payload.data. Each update event provides the new price as a decimal string in payload.value. Timestamps are numbers representing milliseconds since the Unix epoch.
Read the initial snapshot and live updates from the stream.
async with stream: async for event in stream: match event.type: case "subscribe": history = event.payload.data # Use the initial snapshot to populate your chart. case "update": # For example, Decimal("316.1"). price = event.payload.value observed_at = event.payload.timestamp # Update your chart with the new price and its timestamp. case _: continue
The subscribe event provides the initial snapshot in payload.data. Each update event provides the new price as a Decimal in payload.value. Timestamps are UTC datetime objects.For live updates only, set types=["update"]. Omit types or pass an empty list to receive history and updates. Updates may include received_at and is_carried_forward.
Open a WebSocket connection to wss://ws-live-v2.polymarket.com/ws.
Send your CLOB API credentials in the
first frame. Choose the auth frame for the provider you plan to use.
Wait for the authed response, then send a subscription frame. This example
requests AAPL from Pyth. For a Chainlink example, set symbol to eurusd
and provider to chainlink.
Use market status to distinguish a closed market from a price that has stopped
updating. Status describes the instrument priced by the provider, so two
providers can report different states for the same symbol. For example, a
Chainlink series can remain open over a weekend while a Pyth series follows the
underlying exchange’s session hours.
Status
Meaning
open
The provider reports that its instrument’s market is trading.
closed
The provider reports that its instrument’s market is closed.
unknown
The provider cannot determine the market’s state.
Not stated
No status was supplied. Do not assume the market is open.
TypeScript
Python
API
In SDK 0.14.0 and later, read payload.marketStatus on both subscribe snapshots
and update events. Import EquityMarketStatus from @polymarket/client and use
an existing authenticated SecureClient:
import { EquityMarketStatus, PriceProvider } from "@polymarket/client";const stream = await client.subscribe([ { topic: "prices.equity", symbol: "aapl", provider: PriceProvider.Pyth },]);try { for await (const event of stream) { const status = event.payload.marketStatus; if (status === EquityMarketStatus.Closed) { console.log(event.payload.symbol, "Market closed"); } else if (status === EquityMarketStatus.Unknown || status === undefined) { console.log(event.payload.symbol, "Market state unavailable"); } }} finally { await stream.close();}
EquityMarketStatus.Open, .Closed, and .Unknown correspond to the three stated
values. undefined means not stated. The same field is available on
prices.equity.twap. Subscribe with { topic: "prices.equity.twap", symbol: "eurusd", provider: PriceProvider.Chainlink }.
In a snapshot, status is on payload, alongside data, rather than on each
historical price point.
In SDK 0.14.0 and later, read payload.market_status on both subscribe snapshots
and update events. Import EquityMarketStatus from polymarket.streams and use
an existing authenticated AsyncSecureClient:
from polymarket.streams import EquityMarketStatus, EquityPriceSpecasync with await client.subscribe(EquityPriceSpec(symbol="aapl", provider="pyth")) as stream: async for event in stream: status = event.payload.market_status if status == EquityMarketStatus.CLOSED: print(event.payload.symbol, "Market closed") elif status is None or status == EquityMarketStatus.UNKNOWN: print(event.payload.symbol, "Market state unavailable")
EquityMarketStatus.OPEN, .CLOSED, and .UNKNOWN correspond to the three stated
values. None means not stated. For equity TWAP, import EquityTwapPriceSpec from
polymarket.streams and pass EquityTwapPriceSpec(symbol="eurusd", provider="chainlink"). Its payload
has the same market_status field. In a snapshot, read status from payload,
rather than from the historical points in payload.data.
Read payload.market_status on price.equity and price.equity.twap. A missing
field means not stated. On an authenticated PolyBolt WebSocket connection,
send this subscription frame:
See the PolyBolt overview
for the wire contract and provider behavior.
A spot status change can repeat the last price and its timestamp. The update is
marked as carried forward (isCarriedForward in TypeScript,
is_carried_forward in Python and the API). Do not discard an update solely
because its price timestamp repeats: doing so can hide a market close or reopen.
Equity TWAP status changes arrive with a new price.While status is closed or unknown, a snapshot can retain a closing price older
than the usual two-minute history window. Re-read status and source after every
reconnect. SDK cached spot snapshots retain the last stated status when a later
update omits it. A status change on an older price does not roll newer history
back. An unstated live update still has undefined or None for its own status.During market hours, prices can update up to five times per second for each feed.
TWAP Prices
Stream time-weighted average prices (TWAPs) for crypto assets. Each new subscription starts with a snapshot of up to two minutes of recent TWAP values, followed by live updates. Each value represents a 60-second average.Chainlink serves all TWAP feeds. See Chainlink Feeds to set up your API key.
Read the initial snapshot and live updates from the stream.
try { for await (const event of stream) { switch (event.type) { case "subscribe": { const history = event.payload.data; // Use the initial snapshot to populate your chart. break; } case "update": { const price = event.payload.value; // Decimal string, for example "78803.715261094101516288". const observedAt = event.payload.timestamp; // Update your chart with the new price and its timestamp. break; } default: continue; } }} finally { await stream.close();}
The subscribe event provides an initial snapshot in payload.data. Each update event provides the new price as a decimal string in payload.value.Use a canonical symbol such as btcusd. The returned windowSeconds: 60 describes the lookback period, not the update interval. Use payload.timestamp to check price freshness.
from polymarket.streams import CryptoTwapPriceSpecstream = await client.subscribe( CryptoTwapPriceSpec(symbols=["btcusd"], provider="chainlink", provider_api_key="<chainlink_api_key>"))
2
Loop Through the Stream
Read the initial snapshot and live updates from the stream.
async with stream: async for event in stream: match event.type: case "subscribe": history = event.payload.data # Use the initial snapshot to populate your chart. case "update": # For example, Decimal("78803.715261094101516288"). price = event.payload.value observed_at = event.payload.timestamp # Update your chart with the new price and its timestamp. case _: continue
The subscribe event provides an initial snapshot in payload.data. Each update event provides the new price as a Decimal in payload.value. Timestamps are UTC datetime objects.payload.window_seconds is always 60 and describes the lookback window. Use payload.timestamp to check price freshness.
After the subscribed acknowledgement, the first price data frame has
snapshot: true. Use the recent TWAP values in payload.data to populate
your chart.