CCXT

predictfun

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

predictfun

Kind: global class
Extends: Exchange

fetchMarkets

Retrieves all outcome markets from outcomeMeta. Each binary outcome becomes one CCXT prediction market with two outcomes: YES and NO.

Kind: instance method of predictfun
Returns: Array<Market> - array of market structures

See

ParamTypeRequiredDescription
paramsobjectNoextra parameters
params.querystringNoa single search term — routes the call through the search endpoint and returns only the matching markets
params.queriesArray<string>Nomultiple search terms (alternative to query), the results are merged and deduplicated
params.tagsArray<string>Nopredictfun tag ids
params.slugstringNodirect lookup by event slug
params.limitintNothe maximum number of events to collect markets from
predictfun.fetchMarkets (params?)

fetchEvent

fetches a single prediction-market event (market topic)

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

See: https://dev.predict.fun/get-category-by-slug-25326911e0

ParamTypeRequiredDescription
idstringYesevent slug
paramsobjectNoextra parameters specific to the exchange API endpoint
params.slugstringNoevent slug, overrides the id argument when both are given
predictfun.fetchEvent (id, params?)

fetchEvents

fetches prediction-market events (market topics); the call must be scoped by query/queries/tags, eventId, or an l1Category/l2Category listing filter

Kind: instance method of predictfun
Returns: Array<object> - a list of prediction event structures

See

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.querystringNoa single search term — routes the call through GET /v1/search instead of the categories listing
params.queriesArray<string>Nomultiple search terms (alternative to query), searched one by one and merged deduplicated by event slug
params.tagsArray<string>Nopredictfun tag ids
params.slugstringNodirect lookup by event slug
params.limitintNothe maximum number of events to return, capped at 25 per search term when searching
params.sortstringNo'VOLUME_24H_DESC'
params.statusstringNo'OPEN'
params.marketVariantstringNopredictfun enum value ('SPORTS_MATCH', 'CRYPTO_UP_DOWN' etc.)
predictfun.fetchEvents (params?)

fetchOrderBook

fetches the order book for a single prediction outcome token

Kind: instance method of predictfun
Returns: object - a prediction order book structure

See: https://dev.predict.fun/get-the-orderbook-for-a-market-25326908e0

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

fetchTicker

fetches the best bid and ask for a single prediction outcome token

Kind: instance method of predictfun
Returns: object - a prediction ticker structure

See: https://dev.predict.fun/get-market-by-id-25552989e0

ParamTypeRequiredDescription
outcomestringYesunified outcome handle, or an outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.fetchTicker (outcome, params?)

fetchMyTrades

fetches the settled matches the wallet took part in, on either side of the book

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

See: https://dev.predict.fun/get-order-match-events-25663812e0

ParamTypeRequiredDescription
outcomestringNounified outcome handle, restricts the call to that outcome's market
sinceintNotimestamp in ms of the earliest trade to return, applied client side
limitintNothe maximum number of trades to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.afterstringNocursor from a previous response, the venue pages back from the most recent match
params.isSignerMakerboolNotrue keeps only the matches the wallet rested, false only the ones it took
params.signerAddressstringNoread another wallet's matches instead of the configured one
predictfun.fetchMyTrades (outcome?, since?, limit?, params?)

fetchTrades

fetches the most recent settled matches for a single prediction outcome token

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

See: https://dev.predict.fun/get-order-match-events-25663812e0

ParamTypeRequiredDescription
outcomestringYesunified outcome handle, or an outcome token id
sinceintNotimestamp in ms of the earliest trade to return, applied client side
limitintNothe maximum number of trades to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.afterstringNocursor from a previous response, the venue pages back from the most recent match
params.minValueUsdtWeistringNoonly return matches worth at least this many wei
predictfun.fetchTrades (outcome, since?, limit?, params?)

setSandboxMode

switches between BNB mainnet and the BNB testnet

Kind: instance method of predictfun

ParamTypeDescription
enableboolwhether to use the testnet
predictfun.setSandboxMode (enable)

createOrder

creates a LIMIT or MARKET order on a single prediction outcome token

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

See: https://dev.predict.fun/create-an-order-32534694e0

ParamTypeRequiredDescription
outcomestringYesunified outcome handle, or an outcome token id
typestringYes'limit' or 'market'
sidestringYes'buy' or 'sell'
amountfloatYesthe number of outcome shares
pricefloatNothe price per share between 0 and 1, required for a limit order, and for a market order too unless warnOnMarketOrderWithoutPrice is turned off
paramsobjectNoextra parameters specific to the exchange API endpoint
params.expirationintNounix timestamp in seconds the limit order expires at
params.postOnlyboolNoreject the order if it would take liquidity
params.isFillOrKillboolNofill the order completely or cancel it
params.slippageBpsstringNoslippage tolerance for a market order, in basis points
params.warnOnMarketOrderWithoutPriceboolNoset to false to sign a priceless market order at 0.99 to buy or 0.01 to sell, the worst price it accepts
params.selfTradePreventionstringNo'CANCEL_MAKER'
params.saltstringNoorder salt, pin it to retry an order idempotently
params.noncestringNothe maker's on chain nonce, defaults to 0
params.feeRateBpsstringNofee in basis points, read from the market when omitted
params.isNegRiskboolNooverride the market's negative risk flag
params.isYieldBearingboolNooverride the market's yield bearing flag
predictfun.createOrder (outcome, type, side, amount, price?, params?)

fetchPositions

fetches the outcome shares the wallet holds

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

See

ParamTypeRequiredDescription
outcomesArray<string>Nounified outcome handles to keep, all of them when omitted
paramsobjectNoextra parameters specific to the exchange API endpoint
params.addressstringNoread another wallet's positions, which needs no JWT
params.marketIdstringNoonly positions on this market
params.isResolvedboolNoonly resolved, or only unresolved, positions
params.sortstringNo'AMOUNT_DESC'
params.firstintNothe maximum number of positions to return
params.afterstringNocursor from a previous response
predictfun.fetchPositions (outcomes?, params?)

fetchPosition

fetches the shares the wallet holds of a single outcome

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

See: https://dev.predict.fun/get-positions-32675933e0

ParamTypeRequiredDescription
outcomestringYesunified outcome handle, or an outcome token id
paramsobjectNoextra parameters specific to the exchange API endpoint
params.addressstringNoread another wallet's position, which needs no JWT
predictfun.fetchPosition (outcome, params?)

cancelOrder

removes one of your own orders from the order book

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

See: https://dev.predict.fun/remove-orders-by-hash-38139973e0

ParamTypeRequiredDescription
idstringYesthe order hash, as returned by createOrder
outcomestringNounified outcome handle the order belongs to
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.cancelOrder (id, outcome?, params?)

cancelOrders

removes several of your own orders from the order book, up to a hundred at a time

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

See: https://dev.predict.fun/remove-orders-by-hash-38139973e0

ParamTypeRequiredDescription
idsArray<string>Yesthe order hashes, as returned by createOrder
outcomestringNounified outcome handle the orders belong to
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.cancelOrders (ids, outcome?, params?)

fetchOrder

fetches one of your own orders by its hash

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

See: https://dev.predict.fun/get-order-by-hash-25326901e0

ParamTypeRequiredDescription
idstringYesthe order hash
outcomestringNounified outcome handle the order belongs to, resolved from the order when omitted
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.fetchOrder (id, outcome?, params?)

fetchOpenOrders

fetches your own orders that are still resting on the book (only limit orders can be fetched)

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

See: https://dev.predict.fun/get-orders-25326902e0

ParamTypeRequiredDescription
outcomestringNounified outcome handle to filter by, all outcomes when omitted
sinceintNonot used by predictfun fetchOpenOrders, the venue returns no order timestamps
limitintNothe maximum number of orders to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.afterstringNocursor from a previous response, the venue pages back from the newest order
predictfun.fetchOpenOrders (outcome?, since?, limit?, params?)

fetchClosedOrders

fetches your own orders that filled (only limit orders can be fetched)

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

See: https://dev.predict.fun/get-orders-25326902e0

ParamTypeRequiredDescription
outcomestringNounified outcome handle to filter by, all outcomes when omitted
sinceintNonot used by predictfun fetchClosedOrders, the venue returns no order timestamps
limitintNothe maximum number of orders to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.afterstringNocursor from a previous response, the venue pages back from the newest order
predictfun.fetchClosedOrders (outcome?, since?, limit?, params?)

approve

grants the on-chain approvals a wallet needs before it can trade. The buy side is the USDT allowance the exchange spends, without which every order is refused with create_order_insufficient_collateral_allowance; the sell side is the ERC-1155 approval over the outcome shares themselves. WITHOUT params.amount THE BUY SIDE GRANTS AN UNLIMITED (max uint256) ALLOWANCE, pass params.amount to bound it. sends real transactions signed with the privateKey and waits for each receipt, so the wallet needs BNB for gas

Kind: instance method of predictfun
Returns: object - the transaction receipt when buying, and the list of receipts when selling - a neg risk market needs two

See: https://dev.predict.fun/how-to-create-or-cancel-orders-679306m0

ParamTypeRequiredDescription
outcomestringNounified outcome handle, used to pick the contracts its market settles through
paramsobjectNoextra parameters
params.sidestringNo'buy' for the collateral allowance (the default), 'sell' for the outcome share approval
params.spenderstringNoapprove this contract instead of resolving it from the outcome
params.tokenstringNothe contract to grant on, defaults to USDT when buying and to the market's conditional tokens when selling
params.amountfloatNothe allowance in USDT, unlimited when omitted, buy side only
params.approvedboolNopass false to revoke instead of grant, sell side only
params.ownerstringNothe token holder, defaults to walletAddress or the address of the privateKey
params.rpcUrlstringNothe rpc to broadcast through, defaults to the public endpoint for the chain
params.gasLimitstringNogas limit as hex, defaults to 0x186a0
predictfun.approve (outcome?, params?)

watchOrderBook

subscribes to the live order book of an outcome and returns it as it updates

Kind: instance method of predictfun
Returns: object - a prediction order book structure

See: https://dev.predict.fun/subscription-topics-1915507m0

ParamTypeRequiredDescription
outcomestringYesunified outcome handle
limitintNothe maximum number of price levels to return
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.watchOrderBook (outcome, limit?, params?)

unWatchOrderBook

stops watching the order book of an outcome. the venue publishes one book per market and both of its outcomes read it, so the sibling outcome is released with it

Kind: instance method of predictfun
Returns: any - the venue's acknowledgement

See: https://dev.predict.fun/subscription-topics-1915507m0

ParamTypeRequiredDescription
outcomestringYesunified outcome handle
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.unWatchOrderBook (outcome, params?)

watchOrders

watches the wallet's own orders as the venue accepts, fills, expires or cancels them

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

See: https://dev.predict.fun/subscription-topics-1915507m0

ParamTypeRequiredDescription
outcomestringNounified outcome handle to narrow the stream to
sinceintNotimestamp in ms of the earliest order to return
limitintNothe maximum number of orders to return
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.watchOrders (outcome?, since?, limit?, params?)

watchMyTrades

watches the wallet's own fills as they settle on chain

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

See: https://dev.predict.fun/subscription-topics-1915507m0

ParamTypeRequiredDescription
outcomestringNounified outcome handle to narrow the stream to
sinceintNotimestamp in ms of the earliest trade to return
limitintNothe maximum number of trades to return
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.watchMyTrades (outcome?, since?, limit?, params?)

unWatchOrders

stops watching the wallet's orders. one wallet topic carries orders and fills alike, so both streams are released together

Kind: instance method of predictfun
Returns: any - the venue's acknowledgement

See: https://dev.predict.fun/subscription-topics-1915507m0

ParamTypeRequiredDescription
outcomestringNonot used by predictfun.unWatchOrders
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.unWatchOrders (outcome?, params?)

unWatchMyTrades

stops watching the wallet's fills. one wallet topic carries orders and fills alike, so both streams are released together

Kind: instance method of predictfun
Returns: any - the venue's acknowledgement

See: https://dev.predict.fun/subscription-topics-1915507m0

ParamTypeRequiredDescription
outcomestringNonot used by predictfun.unWatchMyTrades
paramsobjectNoextra parameters specific to the exchange API endpoint
predictfun.unWatchMyTrades (outcome?, params?)

On this page