CCXT
polymarket

polymarket

polymarket cryptocurrency exchange — CCXT unified API: methods, parameters and endpoints.

🔌 Looking for raw exchange endpoints? See the polymarket implicit API — every endpoint in this exchange's API exposed as an implicit method.

polymarket

Kind: global class
Extends: Exchange

polymarket

Polymarket perpetual futures - a hybrid dex with an off-chain order book and on-chain settlement of collateral. The venue trades linear perpetual contracts on crypto, indices, equities and commodities, quoted using USD and collateralized exclusively with pUSD. The prediction-market CLOB is a separate product, integrated separately under ccxt.prediction.polymarket

polymarket.polymarket ()

fetchTime

fetches the current integer timestamp in milliseconds from the exchange server

Kind: instance method of polymarket
Returns: int - the current integer timestamp in milliseconds from the exchange server

See: https://docs.polymarket.com/perps/market-data

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

fetchStatus

the latest known information on the availability of the exchange api

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

See: https://docs.polymarket.com/perps/market-data

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

fetchCurrencies

fetches all available currencies on an exchange - every instrument base, the usd quote and the collateral asset

Kind: instance method of polymarket
Returns: object - an associative dictionary of currencies

See: https://docs.polymarket.com/perps/market-data

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

fetchMarkets

retrieves data on all markets for polymarket perps

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

See: https://docs.polymarket.com/perps/market-data

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

fetchTicker

fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market, merging the ticker, statistics and best bid and ask endpoints

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

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchTicker (symbol, params?)

fetchTickers

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market, merging the ticker, statistics and best bid and ask endpoints

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

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchTickers (symbols?, params?)

fetchBidsAsks

fetches the best bid and ask price and volume for multiple markets

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

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchBidsAsks (symbols?, params?)

fetchOrderBook

fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of polymarket
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
limitintNothe maximum amount of order book entries to return, must be one of 10, 100, 500 or 1000, the default is 100
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOrderBook (symbol, limit?, params?)

fetchTrades

get the list of the most recent trades for a particular symbol

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

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum number of trades to fetch, the venue serves at most 100 per request
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest trade to fetch
polymarket.fetchTrades (symbol, since?, limit?, params?)

fetchOHLCV

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

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/perps/market-data

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch OHLCV data for
timeframestringYesthe length of time each candle represents
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum amount of candles to fetch, the venue serves at most 1000 per request
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest candle to fetch
params.paginatebooleanNodefault false, when true will automatically paginate by calling the endpoint multiple times
polymarket.fetchOHLCV (symbol, timeframe, since?, limit?, params?)

fetchFundingRate

fetch the current funding rate

Kind: instance method of polymarket
Returns: object - a funding rate structure

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchFundingRate (symbol, params?)

fetchFundingRates

fetches the current funding rates for multiple markets

Kind: instance method of polymarket
Returns: object - a dictionary of funding rate structures

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolsArray<string>Nounified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchFundingRates (symbols?, params?)

fetchFundingRateHistory

fetches historical funding rate prices

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

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the funding rate history for
sinceintNotimestamp in ms of the earliest funding rate to fetch
limitintNothe maximum amount of funding rate structures to fetch, the venue serves at most 100 per request
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest funding rate to fetch
params.paginatebooleanNodefault false, when true will automatically paginate by calling the endpoint multiple times
polymarket.fetchFundingRateHistory (symbol, since?, limit?, params?)

fetchOpenInterest

retrieves the open interest of a contract trading pair

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

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOpenInterest (symbol, params?)

fetchOpenInterests

retrieves the open interest of multiple contract trading pairs

Kind: instance method of polymarket
Returns: object - a dictionary of open interest structures

See: https://docs.polymarket.com/perps/market-data

ParamTypeRequiredDescription
symbolsArray<string>Nounified market symbols, all markets are returned if not assigned
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOpenInterests (symbols?, params?)

fetchTradingFees

fetches the default trading fees for multiple markets

Kind: instance method of polymarket
Returns: object - a dictionary of fee structures indexed by market symbols

See: https://docs.polymarket.com/perps/learn-about-trading/fees

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

createOrder

create a trade order

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit', a market order executes like an immediate-or-cancel order without a price
sidestringYes'buy' or 'sell'
amountfloatYeshow much you want to trade in units of the base currency
pricefloatNothe price to fulfill the order at, a market order accepts one to act like a protective bound
paramsobjectNoextra parameters specific to the exchange API endpoint
params.timeInForcestringNo'GTC', 'IOC', 'FOK' or 'PO'
params.postOnlyboolNotrue to place a maker only order
params.reduceOnlyboolNotrue to reduce an open position only
params.clientOrderIdstringNoa client order id, exactly 32 lowercase hex characters
params.expintNoexpiry timestamp of the signed command in ms, bounds how long the gateway may hold the request
polymarket.createOrder (symbol, type, side, amount, price?, params?)

createOrders

create a list of trade orders in one signed batch

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
ordersArrayYeslist of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
paramsobjectNoextra parameters specific to the exchange API endpoint
params.expintNoexpiry timestamp of the signed command in ms, bounds how long the gateway may hold the request
polymarket.createOrders (orders, params?)

cancelOrder

cancels an open order

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
idstringYesorder id
symbolstringNonot used by polymarket cancelOrder
paramsobjectNoextra parameters specific to the exchange API endpoint
params.clientOrderIdstringNocancel by the client order id instead of the exchange order id
polymarket.cancelOrder (id, symbol?, params?)

cancelOrders

cancel multiple orders in one signed batch

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
idsArray<string>Yesorder ids
symbolstringNonot used by polymarket cancelOrders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.clientOrderIdsArray<string>Nocancel by client order ids instead of the exchange order ids
polymarket.cancelOrders (ids, symbol?, params?)

cancelAllOrders

cancel all open orders, optionally scoped to a single market

Kind: instance method of polymarket
Returns: Array<object> - a list with the raw acknowledgement of the venue

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringNounified market symbol, cancels the orders of every market when omitted
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.cancelAllOrders (symbol?, params?)

cancelAllOrdersAfter

arms or clears a dead man's switch that cancels every open order once the deadline passes

Kind: instance method of polymarket
Returns: object - the raw acknowledgement of the venue

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
timeoutnumberYestime in milliseconds, 0 represents cancel the timer, the venue requires at least 5 seconds
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.cancelAllOrdersAfter (timeout, params?)

editOrder

edit a resting standalone gtc limit order, only the price and the total quantity can change

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market the order was made in
typestringYesnot used by polymarket editOrder
sidestringYesnot used by polymarket editOrder
amountfloatYesthe new total order quantity, it must exceed the already filled quantity
pricefloatYesthe new order price
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.editOrder (id, symbol, type, side, amount, price, params?)

fetchBalance

query for the account equity, the free order margin and the used initial margin

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

See: https://docs.polymarket.com/perps/trading

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

fetchPositions

fetch all open positions

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolsArray<string>Nolist of unified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchPositions (symbols?, params?)

fetchPosition

fetch data on a single open contract trade position

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market the position is held in
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchPosition (symbol, params?)

fetchOpenOrders

fetch all unfilled currently open orders

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringNounified market symbol
sinceintNonot sent to the venue, applied client-side
limitintNothe maximum number of open order structures to return
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOpenOrders (symbol?, since?, limit?, params?)

fetchOrders

fetches the latest known snapshot of up to one hundred orders

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringNounified market symbol of the market orders were made in
sinceintNotimestamp in ms of the earliest order
limitintNonot sent to the venue, applied client-side
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest order
params.clientOrderIdstringNofetch the order with this client order id only
polymarket.fetchOrders (symbol?, since?, limit?, params?)

fetchOrder

fetches information on an order made by the user

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
idstringYesthe order id
symbolstringNonot used by polymarket fetchOrder
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchOrder (id, symbol?, params?)

fetchMyTrades

fetch all trades made by the user

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringNounified market symbol, the venue serves fills of every market, filtered client-side
sinceintNotimestamp in ms of the earliest trade
limitintNothe maximum number of trade structures to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest trade
params.cursorstringNoopaque pagination cursor returned by the previous page
polymarket.fetchMyTrades (symbol?, since?, limit?, params?)

fetchFundingHistory

fetch the funding payments paid and received on the open positions of the account

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringNounified market symbol
sinceintNotimestamp in ms of the earliest funding payment
limitintNothe maximum number of funding payment structures to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest funding payment
polymarket.fetchFundingHistory (symbol?, since?, limit?, params?)

fetchDeposits

fetch all deposits made to the account

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

See: https://docs.polymarket.com/perps/fund-your-account

ParamTypeRequiredDescription
codestringNounified currency code
sinceintNotimestamp in ms of the earliest deposit
limitintNothe maximum number of transaction structures to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest deposit
polymarket.fetchDeposits (code?, since?, limit?, params?)

fetchWithdrawals

fetch all withdrawals made from the account

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

See: https://docs.polymarket.com/perps/fund-your-account

ParamTypeRequiredDescription
codestringNounified currency code
sinceintNotimestamp in ms of the earliest withdrawal
limitintNothe maximum number of transaction structures to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest withdrawal
polymarket.fetchWithdrawals (code?, since?, limit?, params?)

withdraw

withdraw the collateral asset to the polymarket wallet of the account, the request is signed by the wallet key with the withdraw struct of the deposit contract

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

See: https://docs.polymarket.com/perps/fund-your-account

ParamTypeRequiredDescription
codestringYesunified currency code
amountfloatYesthe amount to withdraw
addressstringYesthe address to withdraw to
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.withdraw (code, amount, address, params?)

fetchLeverage

fetch the leverage and the margin mode configured for a market

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchLeverage (symbol, params?)

fetchMarginMode

fetches the margin mode configured for a market

Kind: instance method of polymarket
Returns: object - a margin mode structure

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.fetchMarginMode (symbol, params?)

setLeverage

set the level of leverage for a market, optionally switching the margin mode at the same time

Kind: instance method of polymarket
Returns: object - the raw acknowledgement of the venue

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
leveragefloatYesthe rate of leverage
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.marginModestringNo'cross' or 'isolated', the venue keeps the current mode when omitted is not supported - the default is cross
polymarket.setLeverage (leverage, symbol, params?)

setMarginMode

set the margin mode of a market, the venue updates the mode and the leverage together

Kind: instance method of polymarket
Returns: object - the raw acknowledgement of the venue

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
marginModestringYes'cross' or 'isolated'
symbolstringNounified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.leveragefloatYesthe rate of leverage to set together with the mode
polymarket.setMarginMode (marginMode, symbol?, params?)

addMargin

add margin to an isolated position

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringYesunified market symbol
amountfloatYesamount of margin to add
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.addMargin (symbol, amount, params?)

reduceMargin

remove margin from an isolated position

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

See: https://docs.polymarket.com/perps/trading

ParamTypeRequiredDescription
symbolstringYesunified market symbol
amountfloatYesthe amount of margin to remove
paramsobjectNoextra parameters specific to the exchange API endpoint
polymarket.reduceMargin (symbol, amount, params?)

createProxyCredentials

provisions fresh trading session credentials - generates a proxy keypair, registers it with an EIP-712 CreateProxy message signed by the wallet key and caches the returned secret, the venue keeps the session valid for the requested lifetime

Kind: instance method of polymarket
Returns: object - the session credentials, holding the proxy address, the proxy private key, the secret and the expiry timestamp

See: https://docs.polymarket.com/perps/authenticated-sessions

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

On this page