Building Market Views
This guide explains how the discovery and orderbook endpoints compose to power a prediction market UI — from the home page event grid down to the live trading view.Live discovery, orderbook, and routing surfaces include active venues only. Retired venue
identifiers can still appear in historical positions, activity, and claim flows.
Data model overview
matchedVenueMarkets hangs off each market, not off the event. See
Matched Clusters for how cross-venue linkage works and which id to use
as a join key.
Key IDs the frontend threads through:
1. Home page — event grid
Fetch the top events sorted by volume. The default sort isvolume desc and the default
feed uses category-interleaved ranking for diversity.
matchedVenueMarkets[]. See Matched Clusters for how
the cluster is assembled and which id to join on.
Response shape (simplified):
title, image, and the first market’s
outcomes. For the price display, batch the page’s venueMarkets[].ids into one
GET /midpoints call (see Bulk midpoint fetch)
and key the returned per-outcome midpoints by venueMarketOutcomeId. If multiple venues are
present, the midpoints response also carries each sibling’s mark so you can show the best
price across venues. Use venues and venueCount to display venue badges (e.g. “Available
on Polymarket + Limitless”) without needing to inspect nested markets.
Pagination: Use cursor for infinite scroll. Pass nextCursor as cursor in the next request.
2. Event detail — market list
When the user clicks an event card, fetch the full event detail including all markets and their cross-venue matches:matchedVenueMarkets — the same market on other venues
with their outcomes.
For the market list, use venue-markets:
GET /venue-events/:id):
matchedVenueMarkets on each market to collect the venueMarket.ids for the
GET /midpoints batch call (cross-venue price comparison) and the
venueMarketOutcome.id values for orderbook subscriptions.
Venue markets response (GET /venue-markets):
GET /midpoints call. matchedVenueMarkets gives you the same
market on other venues — include those ids in the midpoints batch for cross-venue price
comparison.
3. Market detail — live orderbook
When the user selects a specific outcome to trade, fetch the live orderbook.Single-outcome orderbook
For a single outcome on a single venue:Merged cross-venue orderbook (aggregated view)
To show a merged orderbook across multiple venues for the same market, pass multiplevenueMarketIds from matched markets. You get these IDs from matchedVenueMarkets in
step 2.
- From step 2, collect the primary market
idand allmatchedVenueMarkets[].idvalues - Pass them all as
venueMarketIdstoGET /orderbooks - The response groups orderbooks by venue under
venueOrderbooks - Merge bids/asks client-side: combine all venue bids at the same price level, sort descending. Same for asks ascending. Each level shows the total size and per-venue attribution
matchedMarketstells you which other venues have this market and whether they have orderbook data (hasOrderbook)
WebSocket orderbook (live updates)
After the initial REST load, subscribe to the WebSocket for real-time updates. Pass outcome IDs from both the primary and matched markets to receive the aggregated cross-venue stream:4. Bulk midpoint fetch — matched events and markets
When you want a price-comparison view across many events at once (e.g. a homepage grid that shows live “best price across venues”), you typically:- List matched events — only events confirmed to exist on more than one venue.
- Collect every
venueMarketId— the event’s own markets plus theirmatchedVenueMarkets. - Fetch midpoints in one batch call —
GET /midpointsaccepts up to 200 IDs.
List matched events
venueMarkets[] (the event’s markets) and, because we passed
confirmed match statuses, the markets from sibling events on other venues. Walk the response
to gather every venueMarketId you’ll want a midpoint for:
Batch midpoints
Pass the collected IDs to/midpoints. The endpoint proxies the live orderbook engine and
returns the current Yes-side mark per market, plus per-outcome midpoints and the sibling
markets the engine considered.
midpoint, per-outcome midpoints, and the matched siblings
the engine considered. See the API Reference for the
full response schema, including markSource provenance.
For a worked SDK example that compares prices across venues, see
Comparing Venue Prices.
5. Trading — smart route and execution
When the user wants to place a trade, compute the optimal route across venues:order_event messages (step progress, fill confirmation, errors).
Deep cost estimate (deepEstimate=true)
Some venues require one-time setup before a user can trade — ERC-20 and venue
contract approvals on the venue’s chain (Polymarket / Polygon, Limitless /
Base, predict.fun / BNB). These are paid through the gas paymaster on the
user’s first BUY on each (venue, chain) pair and never again.
Add deepEstimate=true to the route call to surface those costs in the
response:
feeBreakdown then includes:
setupCosts— one entry per setup item the route would touch, withkind: "chainApproval" | "venueMarketAta", the cost in USD, and analreadyPaidflag indicating whether the user has already settled it on a prior fill.venueMarketAtaremains in the response type for historical compatibility; active venue routes usechainApproval.setupCostsTotal— sum ofcostUsdfor entries wherealreadyPaid: false. This is also folded into the top-leveltotalCostIncFeesso a single number reflects the realistic total the user will see at execution time.
alreadyPaid to render strike-through “first-time fee”
chips for new users without double-charging returning ones. The deep surface
is buy-only (sells never trigger first-time approvals) and is omitted on
quotes where the engine could not produce an executable plan
(status !== "ok").
End-to-end data flow
Filters reference
/venue-events
/venue-markets
Related
Comparing Venue Prices
Fetch matched events and their midpoints to build a cross-venue price comparison.
WebSocket Protocol
Live orderbook, trades, and order events over WebSocket.
Real-Time Orderbook
SDK and hooks for live orderbook rendering.