Unified Polymarket APIs with Pydantic data validation - Clob, Gamma, Data, Web3, Websockets, GraphQL clients.
The Polymarket ecosystem is organized hierarchically:
flowchart LR
A([Event]) --- B([Market A])
A --- C([Market B])
A ~~~ Dot1@{ shape: sm-circ}
A ~~~ Dot2@{ shape: sm-circ}
A ~~~ Dot3@{ shape: sm-circ}
A -.- D([Market n])
B --- E([Outcome 1])
B --- F([Outcome 2])
C --- G([Outcome 1])
C --- H([Outcome 2])
-
Event — represents a proposition or question such as “How many Fed rate cuts in 2025?”.
- Identified by a human-readable
slug(e.g.how-many-fed-rate-cuts-in-2025) and an eventid(e.g.16085).
- Identified by a human-readable
-
Market — represents a specific option for the related event (e.g. 1 rate cut in 2025). An Event has 1 or more corresponding Markets. (e.g. 9 options in this case - {0, 1, 2, ..., 7, 8 or more} rate cuts in 2025)
- Identified by a
condition id(e.g.0x8e9b6942b4dac3117dadfacac2edb390b6d62d59c14152774bb5fcd983fc134efor 1 rate cut in 2025), a human-readableslug(e.g.'will-1-fed-rate-cut-happen-in-2025') and a marketid(e.g.516724).
- Identified by a
-
Outcome — represents a binary option related to a market. (most commonly
Yes/No, but can be e.g.Paris Saint-Germain/Inter Milanin the case of a match where draws are not possible)- Identified by a
token id(e.g.15353185604353847122370324954202969073036867278400776447048296624042585335546for theYesoutcome in the 1 rate cut in 2025 market)
- Identified by a
-
The different APIs represent Events/Markets differently (e.g. Event, QueryEvent / ClobMarket, GammaMarket, RewardsMarket) but they all use to the same underlying identifiers.
- Tokens are the blockchain implementation of Outcomes - tradable digital assets on the Polygon blockchain that users buy, hold and sell on Polygon.
- This helps ensure the logic of binary outcome prediction markets through smart contracts (e.g. collateralization, token prices going to $1.00 or $0.00 after resolution, splits/merges).
- Holding 1
Yesshare + 1Noshare in a Market (e.g.'will-1-fed-rate-cut-happen-in-2025') covers the entire universe of possibilities and guarantees a $1.00 payout regardless of outcome. This mathematical relationship enables Polymarket's core mechanisms: splitting (1 USDC → 1Yes+ 1No) and merging (1Yes+ 1No→ 1 USDC) at any point before resolution. - Splits are the only way tokens are created. Either a user splits USDC into equal shares of the complementary tokens or Polymarket automatically splits USDC when it matches an
Yesbuy order at e.g. 30¢ with aNobuy order at 70¢.
- Polymarket uses traditional exchange mechanics - a Central Limit Order Book (CLOB), where users place buy and sell orders that get matched by price and time priority.
- However, because the
YesandNooutcomes form a complete probability universe, certain orders become mathematically equivalent - allowing the matching engine to find trades as exemplified above. - This unified structure means every BUY order for
Outcome 1at price X is simultaneously visible as a SELL order forOutcome 2at price (100¢ - X), creating deeper liquidity and tighter spreads than separate order books would allow.
- If the Markets in and Event collectively cover a complete universe of possibilities (e.g. {0, 1, 2, ..., 7, 8 or more} rate cuts in 2025) and only one winner is possible, two collections of positions (made up of tokens and USDC) become mathematically equivalent and the Event is said to support negative risk.
- e.g. Hold 1
Notoken in the 0 rate cuts in 2025. This is equivalent to holding 1Yestoken in each of the other Markets {1, 2, ..., 7, 8 or more}.
- e.g. Hold 1
- An interesting consequence is that holding
Notokens in more than one Market is equivalent toYestokens and some USDC.- e.g. Hold 1
Notoken on each of {0, 1, 2, ..., 7, 8 or more} rate cuts in 2025. Because only one winner is possible, this guarantees that 8 out of the 9 Markets resolve toNo. This is equivalent to a position of 8 USDC. - e.g. Hold 1
Notoken on each of {0, 1} rate cuts in 2025. This is equivalent to 1Yestoken in {2, ..., 7, 8 or more} and 1 USDC.
- e.g. Hold 1
- Polymarket allows for the one way (for capital efficiency) conversion from
Notokens to a collection ofYestokens and USDC before resolution through a smart contract.
-
-
- get one or more order books, best price, spread, midpoint, last trade price by
token_id(s)
- get one or more order books, best price, spread, midpoint, last trade price by
-
- create and post limit or market orders
- cancel one or more orders by
order_id(s) - get active orders
-
- get trade history for a user with filtering by
condition_id,token_id,trade_id, time window
- get trade history for a user with filtering by
-
- check if one or more orders are scoring for liquidity rewards by
order_id(s) - get daily earned rewards
- check if a Market offers rewards by
condition_id- get_market_rewards() - get all active markets that offer rewards sorted by different metrics and ordered, filtered by a query, show your favourites from the web app - get_reward_markets() (naming would do with some work)
- check if one or more orders are scoring for liquidity rewards by
-
- get USDC balance
- get token balance by
token_id - get recent price history by
token_idin the last 1h, 6h, 1d, 1w, 1m - get price history by
token_idin start/end interval - get all price history by
token_idin 2 min increments - get ClobMarket by
condition_id - get all ClobMarkets
-
- get GammaMarket by
market_id - get GammaMarket by
slug - get GammaMarkets with pagination (offset and limit), filter by
slugs,market_ids,token_ids,condition_ids,tag_idor filtered by active, closed, archived, liquidity window, volume window, start date window, end date window and ordered - get Tags for a Market by
market_id
- get GammaMarket by
-
- get Event by
event_id - get Event by
slug - get Events with pagination, filter by
slugs,event_ids,tag_idor filtered by active, closed, archived, liquidity window, volume window, start date window, end date window and ordered - get all Events given some filtration
- search Events, Tags, Profiles, filter by text query, tags, active/resolved, recurrence, sort by volume/volume_24hr/liquidity/start_date/end_date/competitive
- grok event summary by Event
slug - grok election market explanation by candidate name and election title
- get Tags for an Event by
event_id
- get Event by
-
- get Tags with pagination, order by any Tag field
- get all Tags
- get Tag by
tag_id - get Tag relations by
tag_idorslug - get Tags related to a Tag by
tag_idorslug
-
- get Teams with pagination, filter by
league,name,abbreviation - get all Teams given some filtration
- get Sports with pagination, filter by
name - get Sports metadata
- get Teams with pagination, filter by
-
- get Series with pagination, filter by
slug, closed status, order by any Series field - get all Series given some filtration
- get Series with pagination, filter by
-
- get comments by
parent_entity_typeandparent_entity_idwith pagination, order by any Comment field - get comments by
comment_id- gets all comments in a thread. - get comments by user base address (not proxy address) with pagination, order by any Comment field
- get comments by
-
- get positions with pagination (offset and limit) by user address, filter by
condition_id, position size, redeemability, mergeability, title
- get positions with pagination (offset and limit) by user address, filter by
-
- get trades with pagination, filter by
condition id, user address, side, taker only or not, cash amount/token amount
- get trades with pagination, filter by
-
- get activity with pagination by user address, filter by type (trade, split, merge, redeem, reward, conversion),
condition_id, time window, side, sort by timestamp/tokens/cash
- get activity with pagination by user address, filter by type (trade, split, merge, redeem, reward, conversion),
-
- get top holders by
condition_id
- get top holders by
-
- get positions value by user address and condition_ids
condition_idsis None → total value of positionscondition_idsis str → value of positions on a marketcondition_idsis list[str] → sum of values of positions on multiple markets
- get positions value by user address and condition_ids
-
- get closed positions, filter by condition_ids
-
- get total number of markets traded by user address
- get open interest for a list of condition_ids
- get live volume for an event by
event_id - get pnl timeseries by user address for a period (1d, 1w, 1m, all) with frequency (1h, 3h, 12h, 1d)
- get overall pnl/volume by user address for a recent window (1d, 7d, 30d, all)
- get user rank on the profit/volume leaderboards by user address for a recent window (1d, 7d, 30d, all)
- get top users on the profit/volume leaderboards (at most 100) for a recent window (1d, 7d, 30d, all)
-
- EOA(signature_type=0)
- Email/Magic wallets (signature_type=1)
- Safe/Gnosis wallets (signature_type=2)
-
- set approvals for all needed USDC and conditional token spenders (needed for full trading functionality)
- Safe/Gnosis wallet holders need to run deploy_safe before setting approvals
- set approvals for all needed USDC and conditional token spenders (needed for full trading functionality)
-
- get POL balance by user address
- get USDC balance by user address
- get token balance by
token_idand user address
-
- transfer USDC to another address - needs recipient address, amount
- transfer token to another address - needs
token_id, recipient address, amount
-
- split USDC into complementary tokens - needs
condition_id, amount, neg_risk bool - merge complementary tokens into USDC - needs
condition_id, amount, neg_risk bool - redeem token into USDC - needs
condition_id, amounts array [Yesshares,Noshares], neg_risk bool - convert 1 or more
Notokens in a negative risk Event into a collection of USDC andYestokens on the other Markets in the Event
- split USDC into complementary tokens - needs
-
- Email/Magic wallets (signature_type=1)
- Safe/Gnosis wallets (signature_type=2)
-
- balance methods from PolymarketWeb3Client (read only)
- split / merge / convert / redeem (gasless)
- subscribe to market socket with
token_idslist, receive different event types:- order book summary
- price change
- tick size change
- last trade price
- subscribe to user socket with ApiCreds, receive different event types:
- order (status - live, canceled, matched)
- trade (status - matched, mined, confirmed, retrying, failed)
- subscribe to live data socket with any combination described here - newest endpoint - includes the other sockets, receive:
- all of the above event types
- market (created, resolved)
- comment/reaction (created, removed)
- trades/orders_matched (all, not just yours) - filter by Event
slugor Marketslug - crypto price
- request/quote (created, edited, canceled, expired) - rqf not public yet
- instantiate with an endpoint name from:
- activity_subgraph
- fpmm_subgraph
- open_interest_subgraph
- orderbook_subgraph
- pnl_subgraph
- positions_subgraph
- sports_oracle_subgraph
- wallet_subgraph
- query() takes in a GraphQL query string and returns the raw json
-