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.

Base URL
https://tt.opfun.live

Replace with your environment's domain. All responses are JSON with shape { success: boolean, data?: …, error?: { code, message } }.

Markets

List, filter, and inspect prediction markets.

GET/api/marketspublic

List markets with optional tag / category / sort / pagination.

Parameters
tagsstring[]Tag slug(s) to filter on, e.g. politics, crypto.
categorystringSingle category enum filter.
statusstringACTIVE | RESOLVED | INVALID (default ACTIVE).
livebooleanRestrict to live markets (active before close).
sortBystringvolume24h | createdAt | closesAt (default volume).
sortOrderstringasc | desc.
pagenumberPage number, 1-indexed.
limitnumberItems per page, 1..100.
Example
curl 'https://tt.opfun.live/api/markets?tags=politics&limit=5'
GET/api/markets/[marketId]public

Single market by id. Includes prices, vol, event metadata, resolution state.

Example
curl 'https://tt.opfun.live/api/markets/<uuid>'
GET/api/markets/[marketId]/orderbookpublic

Individual open bids + asks for both YES and NO sides. Each row is one order and includes its remaining shares and amount.

Example
curl 'https://tt.opfun.live/api/markets/<uuid>/orderbook'
GET/api/markets/trendingpublic

Top markets by 24h volume.

Parameters
limitnumberdefault 10
GET/api/markets/categoriespublic

Category list with active market counts.

Events

Multi-market events that group related binary markets (PM-style).

GET/api/eventspublic

List events with optional filters.

Parameters
categorystringCategory enum filter.
limitnumberdefault 20
GET/api/events/[slug]public

Single event by slug with all child markets.

Example
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).

POST/api/escrow/ordersession

Submit a signed Order (TM_ORDER_1271_V3). Body includes all signed fields + escrow address.

DELETE/api/escrow/ordersession

Cancel an open order by id, or all of caller's open orders for a market.

Parameters
orderIdstringSingle order id (optional).
marketIdstringCancel all caller's open orders for this market (optional).
POST/api/escrow/increment-noncesession

Mass-cancel: bump on-chain order nonce so every previously signed order becomes invalid at settle. PM CTFExchange.incrementNonce equivalent.

GET/api/tx/[sig]public

Lookup a settled trade or in-flight PendingSettlement by its Solana tx signature.

Example
curl 'https://tt.opfun.live/api/tx/<solana_sig>'
GET/api/tradespublic

Recent trades. Filterable by marketId / userId.

Parameters
marketIdstringLimit to one market.
limitnumberdefault 20

Stats

Public aggregates for accuracy, leaderboard, market metadata.

GET/api/accuracy/statspublic

Resolution composition + hit rate + recent resolutions (used by /accuracy page).

GET/api/leaderboardpublic

Top traders by realised PnL / volume.

Parameters
metricstringpnl | volume
windowstring24h | 7d | 30d | all
GET/api/stats/platformpublic

Overall TVL, active markets, total trades, 24h volume.