predictfun
predictfun prediction-market exchange — CCXT unified API: methods, parameters and endpoints.
predictfun
Kind: global class
Extends: Exchange
- fetchMarkets
- fetchEvent
- fetchEvents
- fetchOrderBook
- fetchTicker
- fetchMyTrades
- fetchTrades
- setSandboxMode
- createOrder
- fetchPositions
- fetchPosition
- cancelOrder
- cancelOrders
- fetchOrder
- fetchOpenOrders
- fetchClosedOrders
- approve
- watchOrderBook
- unWatchOrderBook
- watchOrders
- watchMyTrades
- unWatchOrders
- unWatchMyTrades
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
- https://dev.predict.fun/get-categories-25326910e0
- https://dev.predict.fun/search-categories-and-markets-27399810e0
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters |
| params.query | string | No | a single search term — routes the call through the search endpoint and returns only the matching markets |
| params.queries | Array<string> | No | multiple search terms (alternative to query), the results are merged and deduplicated |
| params.tags | Array<string> | No | predictfun tag ids |
| params.slug | string | No | direct lookup by event slug |
| params.limit | int | No | the 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | event slug |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.slug | string | No | event 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
- https://dev.predict.fun/get-categories-25326910e0
- https://dev.predict.fun/search-categories-and-markets-27399810e0
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.query | string | No | a single search term — routes the call through GET /v1/search instead of the categories listing |
| params.queries | Array<string> | No | multiple search terms (alternative to query), searched one by one and merged deduplicated by event slug |
| params.tags | Array<string> | No | predictfun tag ids |
| params.slug | string | No | direct lookup by event slug |
| params.limit | int | No | the maximum number of events to return, capped at 25 per search term when searching |
| params.sort | string | No | 'VOLUME_24H_DESC' |
| params.status | string | No | 'OPEN' |
| params.marketVariant | string | No | predictfun 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome handle, or an outcome token id |
| limit | int | No | not used by predictfun fetchOrderBook |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome handle, or an outcome token id |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome handle, restricts the call to that outcome's market |
| since | int | No | timestamp in ms of the earliest trade to return, applied client side |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.after | string | No | cursor from a previous response, the venue pages back from the most recent match |
| params.isSignerMaker | bool | No | true keeps only the matches the wallet rested, false only the ones it took |
| params.signerAddress | string | No | read 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome handle, or an outcome token id |
| since | int | No | timestamp in ms of the earliest trade to return, applied client side |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.after | string | No | cursor from a previous response, the venue pages back from the most recent match |
| params.minValueUsdtWei | string | No | only 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
| Param | Type | Description |
|---|---|---|
| enable | bool | whether 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome handle, or an outcome token id |
| type | string | Yes | 'limit' or 'market' |
| side | string | Yes | 'buy' or 'sell' |
| amount | float | Yes | the number of outcome shares |
| price | float | No | the price per share between 0 and 1, required for a limit order, and for a market order too unless warnOnMarketOrderWithoutPrice is turned off |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.expiration | int | No | unix timestamp in seconds the limit order expires at |
| params.postOnly | bool | No | reject the order if it would take liquidity |
| params.isFillOrKill | bool | No | fill the order completely or cancel it |
| params.slippageBps | string | No | slippage tolerance for a market order, in basis points |
| params.warnOnMarketOrderWithoutPrice | bool | No | set to false to sign a priceless market order at 0.99 to buy or 0.01 to sell, the worst price it accepts |
| params.selfTradePrevention | string | No | 'CANCEL_MAKER' |
| params.salt | string | No | order salt, pin it to retry an order idempotently |
| params.nonce | string | No | the maker's on chain nonce, defaults to 0 |
| params.feeRateBps | string | No | fee in basis points, read from the market when omitted |
| params.isNegRisk | bool | No | override the market's negative risk flag |
| params.isYieldBearing | bool | No | override 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
- https://dev.predict.fun/get-positions-32675933e0
- https://dev.predict.fun/get-positions-by-address-32675934e0
| Param | Type | Required | Description |
|---|---|---|---|
| outcomes | Array<string> | No | unified outcome handles to keep, all of them when omitted |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.address | string | No | read another wallet's positions, which needs no JWT |
| params.marketId | string | No | only positions on this market |
| params.isResolved | bool | No | only resolved, or only unresolved, positions |
| params.sort | string | No | 'AMOUNT_DESC' |
| params.first | int | No | the maximum number of positions to return |
| params.after | string | No | cursor 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome handle, or an outcome token id |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.address | string | No | read 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order hash, as returned by createOrder |
| outcome | string | No | unified outcome handle the order belongs to |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| ids | Array<string> | Yes | the order hashes, as returned by createOrder |
| outcome | string | No | unified outcome handle the orders belong to |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order hash |
| outcome | string | No | unified outcome handle the order belongs to, resolved from the order when omitted |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome handle to filter by, all outcomes when omitted |
| since | int | No | not used by predictfun fetchOpenOrders, the venue returns no order timestamps |
| limit | int | No | the maximum number of orders to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.after | string | No | cursor 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome handle to filter by, all outcomes when omitted |
| since | int | No | not used by predictfun fetchClosedOrders, the venue returns no order timestamps |
| limit | int | No | the maximum number of orders to return |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.after | string | No | cursor 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome handle, used to pick the contracts its market settles through |
| params | object | No | extra parameters |
| params.side | string | No | 'buy' for the collateral allowance (the default), 'sell' for the outcome share approval |
| params.spender | string | No | approve this contract instead of resolving it from the outcome |
| params.token | string | No | the contract to grant on, defaults to USDT when buying and to the market's conditional tokens when selling |
| params.amount | float | No | the allowance in USDT, unlimited when omitted, buy side only |
| params.approved | bool | No | pass false to revoke instead of grant, sell side only |
| params.owner | string | No | the token holder, defaults to walletAddress or the address of the privateKey |
| params.rpcUrl | string | No | the rpc to broadcast through, defaults to the public endpoint for the chain |
| params.gasLimit | string | No | gas 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome handle |
| limit | int | No | the maximum number of price levels to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | Yes | unified outcome handle |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome handle to narrow the stream to |
| since | int | No | timestamp in ms of the earliest order to return |
| limit | int | No | the maximum number of orders to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | unified outcome handle to narrow the stream to |
| since | int | No | timestamp in ms of the earliest trade to return |
| limit | int | No | the maximum number of trades to return |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | not used by predictfun.unWatchOrders |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| outcome | string | No | not used by predictfun.unWatchMyTrades |
| params | object | No | extra parameters specific to the exchange API endpoint |
predictfun.unWatchMyTrades (outcome?, params?)