polymarket
polymarket prediction-market exchange — CCXT unified API: methods, parameters and endpoints.
polymarket
Kind: global class
Extends: Exchange
- fetchMarkets
- fetchTicker
- fetchTickers
- fetchOrderBook
- fetchOHLCV
- fetchTime
- fetchStatus
- fetchOpenInterest
- fetchTradingFee
- fetchTrades
- fetchMyTrades
- fetchOrderTrades
- fetchBalance
- fetchPositions
- fetchPosition
- fetchOpenOrders
- fetchOrder
- createOrder
- createOrders
- createMarketBuyOrderWithCost
- cancelOrder
- cancelOrders
- cancelAllOrders
- fetchEvents
- fetchEvent
- deriveApiKey
- createApiKey
- createOrDeriveApiKey
- watchOrderBook
- watchTrades
- watchTicker
- watchOrders
- watchMyTrades
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
- https://docs.polymarket.com/api-reference/events/list-events
- https://docs.polymarket.com/api-reference/search/search-markets-events-and-profiles
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra exchange-specific parameters |
| params.query | string | No | a single search term used to filter the fetched events |
| params.queries | Array<string> | No | multiple search terms (alternative to query) |
| params.status | string | No | 'active', 'closed' or 'all', the status of the events to fetch, defaults to 'active' |
| params.limit | int | No | max 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
- https://docs.polymarket.com/api-reference/data/get-midpoint-price
- https://docs.polymarket.com/api-reference/market-data/get-order-book
- https://docs.polymarket.com/api-reference/data/get-last-trade-price
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome like TRUMP_DANCE_TODAY_997:YES or an outcome token id |
| params | object | No | extra 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
- https://docs.polymarket.com/api-reference/market-data/get-order-books-request-body
- https://docs.polymarket.com/api-reference/market-data/get-midpoint-prices-request-body
- https://docs.polymarket.com/api-reference/data/get-last-trades-prices
| Param | Type | Required | Description |
|---|---|---|---|
| outcomes | Array<string> | Yes | unified outcomes or outcome token ids — required: polymarket has no endpoint returning all tickers at once, so an unscoped call is not supported |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| limit | int | No | not used by polymarket fetchOrderBook |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| timeframe | string | Yes | the length of time each candle represents |
| since | int | No | timestamp in ms of the earliest candle to fetch |
| limit | int | No | the maximum number of candles to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| since | int | No | not used by polymarket fetchTrades |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome or outcome token id |
| since | int | No | the earliest time in ms to fetch trades for |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order id |
| outcome | string | No | unified outcome or outcome token id to narrow the lookup |
| since | int | No | the earliest time in ms to fetch trades for |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.signatureType | int | No | 0=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
| Param | Type | Required | Description |
|---|---|---|---|
| outcomes | Array<string> | No | unified outcomes to filter by |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome or outcome token id |
| since | int | No | not used by polymarket fetchOpenOrders |
| limit | int | No | the maximum number of orders to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order id |
| outcome | string | No | unified outcome or outcome token id |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| type | string | Yes | 'market' or 'limit'; market orders default to FOK and, when no price is given, use the outcome's current price as the marketable reference |
| side | string | Yes | 'buy' or 'sell' |
| amount | float | Yes | how many outcome tokens to trade |
| price | float | No | the price per outcome token between 0 and 1; required for limit orders, defaults to the outcome's current price for market orders |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.orderType | string | No | time-in-force override: 'GTC' (default for limit), 'FOK' (default for market), 'GTD' or 'FAK' |
| params.signatureType | int | No | 0=EOA, 1=POLY_PROXY, 2=GNOSIS_SAFE, 3=POLY_1271 (deposit wallet); defaults to options.signatureType |
| params.funder | string | No | the wallet that holds the USDC collateral; defaults to options.funder or the signing address |
| params.tickSize | string | No | the market tick size ('0.1'/'0.01'/'0.001'/'0.0001'); read from the outcome when omitted |
| params.negRisk | bool | No | whether the market is a neg-risk market; read from the outcome when omitted |
| params.salt | string | No | order salt; defaults to the current time in ms (pin it for idempotent retries) |
| params.timestamp | string | No | order timestamp; defaults to the current time in ms |
| params.expiration | string | No | unix-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
| Param | Type | Required | Description |
|---|---|---|---|
| orders | Array<object> | Yes | a list of order requests, each an object with outcome, type, side, amount, price and optional params (same params as createOrder) |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome or outcome token id |
| cost | float | Yes | the amount of USDC to spend |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order id |
| outcome | string | No | unified outcome or outcome token id |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| ids | Array<string> | Yes | the order ids to cancel |
| outcome | string | No | not used by polymarket cancelOrders |
| params | object | No | extra 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
- https://docs.polymarket.com/api-reference/trade/cancel-all-orders
- https://docs.polymarket.com/api-reference/trade/cancel-market-orders
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome or outcome token id; when given only that outcome's orders are cancelled |
| params | object | No | extra 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
- https://docs.polymarket.com/api-reference/search/search-markets-events-and-profiles
- https://docs.polymarket.com/api-reference/events/list-events
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra exchange-specific parameters |
| params.query | string | No | a single keyword search term |
| params.queries | Array<string> | No | multiple search terms (alternative to query) |
| params.limit | int | No | max number of events to return |
| params.sort | string | No | 'volume' (default), 'liquidity' or 'newest' — mapped to the gamma order field |
| params.status | string | No | 'active' (default), 'inactive', 'closed' or 'all' ('inactive' and 'closed' are interchangeable) |
| params.searchIn | string | No | when searching, restrict the match to 'title' (default), 'description' or 'both' |
| params.eventId | string | No | direct lookup by event id (short-circuits the listing/search) |
| params.slug | string | No | direct lookup by event slug |
| params.searchPageSize | int | No | search 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.maxSearchPages | int | No | max 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
- https://docs.polymarket.com/api-reference/events/get-event-by-id
- https://docs.polymarket.com/api-reference/events/get-event-by-slug
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the event id (numeric) or slug |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.nonce | int | No | the 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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.nonce | int | No | the 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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome (e.g. "TRUMP_WINS_2028:YES") or an outcome token id |
| limit | int | No | optional depth limit applied after resolving |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome |
| since | int | No | optional unix timestamp (ms) lower bound |
| limit | int | No | optional max number of trades to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome to filter the stream to one market |
| since | int | No | the earliest time in ms to return orders for |
| limit | int | No | the maximum number of orders to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome to filter the stream to one market |
| since | int | No | the earliest time in ms to return trades for |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
polymarket.watchMyTrades (outcome?, since?, limit?, params?)