CCXT

polymarket

polymarket prediction-market exchange — CCXT unified API: methods, parameters and endpoints.

polymarket

Kind: global class
Extends: Exchange

fetchMarkets

retrieves data on all markets for polymarket, each prediction market becomes one market with its outcome tokens listed under the outcomes key

Kind: instance method of polymarket
Returns: Array<object> - an array of objects representing market data

See

ParamTypeRequiredDescription
paramsobjectNoextra exchange-specific parameters
params.querystringNoa single search term used to filter the fetched events
params.queriesArray<string>Nomultiple search terms (alternative to query)
params.statusstringNo'active', 'closed' or 'all', the status of the events to fetch, defaults to 'active'
params.limitintNomax number of events to fetch when no query is given (defaults to options.fetchMarketsLimit, 200); the listing is ordered by 24h volume so the most active markets come first — outcomes on lower-volume markets are resolvable on demand by their token id (fetchOutcome)
polymarket.fetchMarkets (params?)

fetchTicker

fetches the current mid-price and best bid/ask for a single outcome token

Kind: instance method of polymarket
Returns: object - a ticker structure

See

ParamTypeRequiredDescription
outcomestringYesunified outcome like TRUMP_DANCE_TODAY_997:YES or an outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchTicker (outcome, params?)

fetchTickers

fetches tickers for multiple outcome tokens at once using the batched CLOB book, midpoint and last-trade-price endpoints (200 per request trio)

Kind: instance method of polymarket
Returns: object - a dictionary of ticker structures indexed by outcome

See

ParamTypeRequiredDescription
outcomesArray<string>Yesunified outcomes or outcome token ids — required: polymarket has no endpoint returning all tickers at once, so an unscoped call is not supported
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchTickers (outcomes, params?)

fetchOrderBook

fetches the CLOB order book for a single outcome token

Kind: instance method of polymarket
Returns: object - an order book structure

See: https://docs.polymarket.com/api-reference/market-data/get-order-book

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
limitintNonot used by polymarket fetchOrderBook
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOrderBook (outcome, limit?, params?)

fetchOHLCV

fetches price history ticks for a single outcome token and buckets them client-side into OHLCV candles, snapping tick timestamps to the candle boundary

Kind: instance method of polymarket
Returns: Array<Array<int>> - a list of candles ordered as timestamp, open, high, low, close, volume

See: https://docs.polymarket.com/api-reference/markets/get-prices-history

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
timeframestringYesthe length of time each candle represents
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum number of candles to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOHLCV (outcome, timeframe, since?, limit?, params?)

fetchTime

fetches the current timestamp from the CLOB server

Kind: instance method of polymarket
Returns: int - the current server time in milliseconds

See: https://docs.polymarket.com/api-reference/data/get-server-time

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchTime (params?)

fetchStatus

fetches the gamma API health status

Kind: instance method of polymarket
Returns: object - a status structure

See: https://docs.polymarket.com/api-reference/events/list-events

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchStatus (params?)

fetchOpenInterest

fetches the open interest of a prediction market outcome

Kind: instance method of polymarket
Returns: object - an open interest structure

See: https://docs.polymarket.com/api-reference/misc/get-open-interest

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOpenInterest (outcome, params?)

fetchTradingFee

fetches the base fee rate for a prediction market outcome token

Kind: instance method of polymarket
Returns: object - a fee structure

See: https://docs.polymarket.com/api-reference/market-data/get-fee-rate

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchTradingFee (outcome, params?)

fetchTrades

fetches public trade history for a single outcome token from the data API

Kind: instance method of polymarket
Returns: Array<object> - a list of trade structures

See: https://docs.polymarket.com/api-reference/core/get-trades-for-a-user-or-markets

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
sinceintNonot used by polymarket fetchTrades
limitintNothe maximum number of trades to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchTrades (outcome, since?, limit?, params?)

fetchMyTrades

fetches the authenticated user's trade history from the CLOB, optionally filtered by outcome token

Kind: instance method of polymarket
Returns: Array<object> - a list of trade structures

See: https://docs.polymarket.com/api-reference/trade/get-trades

ParamTypeRequiredDescription
outcomestringNounified outcome or outcome token id
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trades to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchMyTrades (outcome?, since?, limit?, params?)

fetchOrderTrades

fetches all the trades made from a single order

Kind: instance method of polymarket
Returns: Array<object> - a list of trade structures

See: https://docs.polymarket.com/api-reference/trade/get-trades

ParamTypeRequiredDescription
idstringYesthe order id
outcomestringNounified outcome or outcome token id to narrow the lookup
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trades to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOrderTrades (id, outcome?, since?, limit?, params?)

fetchBalance

fetches the USDC collateral balance available for trading on the CLOB

Kind: instance method of polymarket
Returns: object - a balance structure

See: https://docs.polymarket.com/api-reference/trade/get-balance-allowance

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.signatureTypeintNo0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE, 3=POLY_1271 (deposit wallet); defaults to options.signatureType
polymarket.fetchBalance (params?)

fetchPositions

fetches open outcome token positions for the wallet from the data API

Kind: instance method of polymarket
Returns: Array<object> - a list of position structures

See: https://docs.polymarket.com/api-reference/core/get-current-positions-for-a-user

ParamTypeRequiredDescription
outcomesArray<string>Nounified outcomes to filter by
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchPositions (outcomes?, params?)

fetchPosition

fetches the open position for a single outcome token

Kind: instance method of polymarket
Returns: object - a position structure

See: https://docs.polymarket.com/api-reference/core/get-current-positions-for-a-user

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchPosition (outcome, params?)

fetchOpenOrders

fetches open resting orders for the authenticated user, optionally filtered by outcome token

Kind: instance method of polymarket
Returns: Array<object> - a list of order structures

See: https://docs.polymarket.com/api-reference/trade/get-user-orders

ParamTypeRequiredDescription
outcomestringNounified outcome or outcome token id
sinceintNonot used by polymarket fetchOpenOrders
limitintNothe maximum number of orders to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOpenOrders (outcome?, since?, limit?, params?)

fetchOrder

fetches a single order by id from the CLOB private data endpoint

Kind: instance method of polymarket
Returns: object - an order structure

See: https://docs.polymarket.com/api-reference/trade/get-single-order-by-id

ParamTypeRequiredDescription
idstringYesthe order id
outcomestringNounified outcome or outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOrder (id, outcome?, params?)

createOrder

places a limit or market order on the CLOB for the given outcome token

Kind: instance method of polymarket
Returns: object - an order structure

See: https://docs.polymarket.com/api-reference/trade/post-a-new-order

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
typestringYes'market' or 'limit'; market orders default to FOK and, when no price is given, use the outcome's current price as the marketable reference
sidestringYes'buy' or 'sell'
amountfloatYeshow many outcome tokens to trade
pricefloatNothe price per outcome token between 0 and 1; required for limit orders, defaults to the outcome's current price for market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.orderTypestringNotime-in-force override: 'GTC' (default for limit), 'FOK' (default for market), 'GTD' or 'FAK'
params.signatureTypeintNo0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE, 3=POLY_1271 (deposit wallet); defaults to options.signatureType
params.funderstringNothe wallet that holds the USDC collateral; defaults to options.funder or the signing address
params.tickSizestringNothe market tick size ('0.1'/'0.01'/'0.001'/'0.0001'); read from the outcome when omitted
params.negRiskboolNowhether the market is a neg-risk market; read from the outcome when omitted
params.saltstringNoorder salt; defaults to the current time in ms (pin it for idempotent retries)
params.timestampstringNoorder timestamp; defaults to the current time in ms
params.expirationstringNounix-seconds expiration for GTD orders; defaults to '0' (no expiry)
polymarket.createOrder (outcome, type, side, amount, price?, params?)

createOrders

places multiple orders on the CLOB in a single batched request

Kind: instance method of polymarket
Returns: Array<object> - a list of order structures

See: https://docs.polymarket.com/api-reference/trade/post-orders

ParamTypeRequiredDescription
ordersArray<object>Yesa list of order requests, each an object with outcome, type, side, amount, price and optional params (same params as createOrder)
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.createOrders (orders, params?)

createMarketBuyOrderWithCost

places a market buy order sized by USDC cost (how much to spend) rather than shares

Kind: instance method of polymarket
Returns: object - an order structure

See: https://docs.polymarket.com/api-reference/trade/post-a-new-order

ParamTypeRequiredDescription
outcomestringYesunified outcome or outcome token id
costfloatYesthe amount of USDC to spend
paramsobjectNoextra parameters specific to the exchange API endpoint (see createOrder)
polymarket.createMarketBuyOrderWithCost (outcome, cost, params?)

cancelOrder

cancels a single open order by id on the CLOB

Kind: instance method of polymarket
Returns: object - an order structure

See: https://docs.polymarket.com/api-reference/trade/cancel-single-order

ParamTypeRequiredDescription
idstringYesthe order id
outcomestringNounified outcome or outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.cancelOrder (id, outcome?, params?)

cancelOrders

cancels multiple open orders by id on the CLOB in a single request

Kind: instance method of polymarket
Returns: Array<object> - a list of order structures

See: https://docs.polymarket.com/api-reference/trade/cancel-orders

ParamTypeRequiredDescription
idsArray<string>Yesthe order ids to cancel
outcomestringNonot used by polymarket cancelOrders
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.cancelOrders (ids, outcome?, params?)

cancelAllOrders

cancels all open orders on the CLOB, optionally scoped to one outcome token

Kind: instance method of polymarket
Returns: Array<object> - a list of order structures

See

ParamTypeRequiredDescription
outcomestringNounified outcome or outcome token id; when given only that outcome's orders are cancelled
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.cancelAllOrders (outcome?, params?)

fetchEvents

fetches prediction-market events matching the given scope (query/queries/tags/eventId/slug — required) and caches their markets and outcomes on the instance; for an unscoped top-volume browse use fetchMarkets ()

Kind: instance method of polymarket
Returns: Array<object> - an array of event structures

See

ParamTypeRequiredDescription
paramsobjectNoextra exchange-specific parameters
params.querystringNoa single keyword search term
params.queriesArray<string>Nomultiple search terms (alternative to query)
params.limitintNomax number of events to return
params.sortstringNo'volume' (default), 'liquidity' or 'newest' — mapped to the gamma order field
params.statusstringNo'active' (default), 'inactive', 'closed' or 'all' ('inactive' and 'closed' are interchangeable)
params.searchInstringNowhen searching, restrict the match to 'title' (default), 'description' or 'both'
params.eventIdstringNodirect lookup by event id (short-circuits the listing/search)
params.slugstringNodirect lookup by event slug
params.searchPageSizeintNosearch page size (gamma limit_per_type, default 100); lower it to shrink the download when a small limit is enough, higher to over-fetch before client-side status/title filtering
params.maxSearchPagesintNomax search pages to fetch when no limit is given (default 5), bounding a broad query
polymarket.fetchEvents (params?)

fetchEvent

fetches a single prediction-market event by its id or slug

Kind: instance method of polymarket
Returns: object - a prediction event structure

See

ParamTypeRequiredDescription
idstringYesthe event id (numeric) or slug
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchEvent (id, params?)

deriveApiKey

derives the L2 api credentials (apiKey, secret, passphrase) deterministically from the wallet private key

Kind: instance method of polymarket
Returns: object - the api credentials { apiKey, secret, passphrase }

See: https://docs.polymarket.com/developers/CLOB/authentication

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.nonceintNothe nonce used to derive the credentials, defaults to 0
polymarket.deriveApiKey (params?)

createApiKey

creates new L2 api credentials (apiKey, secret, passphrase) for the wallet private key

Kind: instance method of polymarket
Returns: object - the api credentials { apiKey, secret, passphrase }

See: https://docs.polymarket.com/developers/CLOB/authentication

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.nonceintNothe nonce used to create the credentials, defaults to 0
polymarket.createApiKey (params?)

createOrDeriveApiKey

derives the existing L2 api credentials for the wallet private key, creating them if none exist yet

Kind: instance method of polymarket
Returns: object - the api credentials { apiKey, secret, passphrase }

See: https://docs.polymarket.com/developers/CLOB/authentication

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.createOrDeriveApiKey (params?)

watchOrderBook

streams live order-book updates for a single Polymarket outcome token

Kind: instance method of polymarket
Returns: object - an order book structure

ParamTypeRequiredDescription
outcomestringYesunified outcome (e.g. "TRUMP_WINS_2028:YES") or an outcome token id
limitintNooptional depth limit applied after resolving
paramsobjectNoextra params (currently unused)
polymarket.watchOrderBook (outcome, limit?, params?)

watchTrades

streams live fills for a single Polymarket outcome token

Kind: instance method of polymarket
Returns: Array<object> - a list of trade structures

ParamTypeRequiredDescription
outcomestringYesunified outcome
sinceintNooptional unix timestamp (ms) lower bound
limitintNooptional max number of trades to return
paramsobjectNoextra params (unused)
polymarket.watchTrades (outcome, since?, limit?, params?)

watchTicker

streams a synthetic ticker derived from order-book snapshots and deltas (mid = (bid + ask) / 2)

Kind: instance method of polymarket
Returns: object - a ticker structure

ParamTypeRequiredDescription
outcomestringYesunified outcome
paramsobjectNoextra params (unused)
polymarket.watchTicker (outcome, params?)

watchOrders

watches the authenticated user's order updates over the CLOB user websocket channel

Kind: instance method of polymarket
Returns: Array<object> - a list of order structures

See: https://docs.polymarket.com/developers/CLOB/websocket/user-channel

ParamTypeRequiredDescription
outcomestringNounified outcome to filter the stream to one market
sinceintNothe earliest time in ms to return orders for
limitintNothe maximum number of orders to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.watchOrders (outcome?, since?, limit?, params?)

watchMyTrades

watches the authenticated user's trade fills over the CLOB user websocket channel

Kind: instance method of polymarket
Returns: Array<object> - a list of trade structures

See: https://docs.polymarket.com/developers/CLOB/websocket/user-channel

ParamTypeRequiredDescription
outcomestringNounified outcome to filter the stream to one market
sinceintNothe earliest time in ms to return trades for
limitintNothe maximum number of trades to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.watchMyTrades (outcome?, since?, limit?, params?)

On this page