MarketFetcher Setup
MarketFetcher provides read-only access to market data. No API key is required for public endpoints.
Active Markets
Retrieve a paginated list of currently active markets with optional sorting.Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 10 | Number of markets per page |
page | number | 1 | Page number (1-indexed) |
sortBy | string | 'newest' | Sort order for results |
Sort Options
| Value | Description |
|---|---|
'lp_rewards' | Markets with the highest LP rewards |
'ending_soon' | Markets closest to resolution |
'newest' | Most recently created markets |
'high_value' | Markets with the highest volume or liquidity |
Single Market
Fetch a single market by slug. The response includes venue contract addresses and token IDs needed for trading.getMarket() automatically caches the venue data for the returned market. Subsequent calls for the same slug return the cached result. Always fetch the market before placing orders to ensure the venue is cached.Market Response Structure
Orderbook
Fetch the current orderbook for a CLOB market. Returns bids, asks, and the current spread.Orderbook Response Structure
User Orders
Retrieve your open orders for a specific market using the fluent API. Requires an API key.The
getUserOrders() method is available on the market object returned by getMarket(). It requires an authenticated HttpClient (with an API key).NegRisk Group Markets
NegRisk markets are organized into groups. Each group contains multiple submarkets (outcomes). To trade a specific outcome, fetch the group first, then access the submarket you need.Best Practices
Cache venue data
Cache venue data
Always call
getMarket() before placing orders. The SDK caches venue data (exchange and adapter addresses) internally. This avoids redundant API calls and ensures the OrderClient has the information it needs to sign orders.Use WebSocket instead of polling
Use WebSocket instead of polling
For real-time orderbook data, subscribe to WebSocket events rather than polling
getOrderBook(). The WebSocket pushes orderbookUpdate events whenever the book changes, reducing latency and API usage. See the WebSocket Streaming guide.Paginate large result sets
Paginate large result sets
When fetching active markets, always use
limit and page parameters. Requesting unbounded result sets can cause timeouts and high memory usage.