API Reference
Read endpoints are public and require no auth. Write endpoints (placing orders, mass-cancel) require a session — sign in with your Solana wallet first.
https://tt.opfun.liveReplace with your environment's domain. All responses are JSON with shape { success: boolean, data?: …, error?: { code, message } }.
Markets
List, filter, and inspect prediction markets.
/api/marketspublicList markets with optional tag / category / sort / pagination.
| tags | string[] | Tag slug(s) to filter on, e.g. politics, crypto. |
| category | string | Single category enum filter. |
| status | string | ACTIVE | RESOLVED | INVALID (default ACTIVE). |
| live | boolean | Restrict to live markets (active before close). |
| sortBy | string | volume24h | createdAt | closesAt (default volume). |
| sortOrder | string | asc | desc. |
| page | number | Page number, 1-indexed. |
| limit | number | Items per page, 1..100. |
curl 'https://tt.opfun.live/api/markets?tags=politics&limit=5'
/api/markets/[marketId]publicSingle market by id. Includes prices, vol, event metadata, resolution state.
curl 'https://tt.opfun.live/api/markets/<uuid>'
/api/markets/[marketId]/orderbookpublicIndividual open bids + asks for both YES and NO sides. Each row is one order and includes its remaining shares and amount.
curl 'https://tt.opfun.live/api/markets/<uuid>/orderbook'
/api/markets/trendingpublicTop markets by 24h volume.
| limit | number | default 10 |
/api/markets/categoriespublicCategory list with active market counts.
Events
Multi-market events that group related binary markets (PM-style).
/api/eventspublicList events with optional filters.
| category | string | Category enum filter. |
| limit | number | default 20 |
/api/events/[slug]publicSingle event by slug with all child markets.
curl 'https://tt.opfun.live/api/events/<slug>'
Trading
Place signed orders, view your orders, query trades by signature. Most write paths require a Solana wallet signature (session cookie).
/api/escrow/ordersessionSubmit a signed Order (TM_ORDER_1271_V3). Body includes all signed fields + escrow address.
/api/escrow/ordersessionCancel an open order by id, or all of caller's open orders for a market.
| orderId | string | Single order id (optional). |
| marketId | string | Cancel all caller's open orders for this market (optional). |
/api/escrow/increment-noncesessionMass-cancel: bump on-chain order nonce so every previously signed order becomes invalid at settle. PM CTFExchange.incrementNonce equivalent.
/api/tx/[sig]publicLookup a settled trade or in-flight PendingSettlement by its Solana tx signature.
curl 'https://tt.opfun.live/api/tx/<solana_sig>'
/api/tradespublicRecent trades. Filterable by marketId / userId.
| marketId | string | Limit to one market. |
| limit | number | default 20 |
Stats
Public aggregates for accuracy, leaderboard, market metadata.
/api/accuracy/statspublicResolution composition + hit rate + recent resolutions (used by /accuracy page).
/api/leaderboardpublicTop traders by realised PnL / volume.
| metric | string | pnl | volume |
| window | string | 24h | 7d | 30d | all |
/api/stats/platformpublicOverall TVL, active markets, total trades, 24h volume.