Fetching Markets
Openfish offers multiple ways to retrieve market data, each suited to different integration patterns. All list endpoints support pagination through limit and offset parameters.
Strategy 1: REST Polling via Gamma API
Section titled “Strategy 1: REST Polling via Gamma API”The most direct method. Query the Gamma API for events or markets, applying filters and pagination as needed.
Fetch App-Ready Active Markets
Section titled “Fetch App-Ready Active Markets”The public app starts from the CLOB Browse API because it includes current Openfish volume, trade counts, creator data, outcome prices, and localization:
curl "https://api.openfish.me/browse/markets?status=LIVE&limit=50"Fetch World Cup Games by Match
Section titled “Fetch World Cup Games by Match”Use the World Cup topic when you need a game-first view instead of a flat market list:
curl "https://api.openfish.me/browse/topics/world-cup/games?view=list"The lightweight list view preserves full match rollups but includes only match-result markets, so list pages can subscribe only to winner/draw/away prices. Fetch one full match on demand with eventSlug when the user expands a game.
Fetch Active Events From Gamma
Section titled “Fetch Active Events From Gamma”curl "https://gamma.openfish.me/events?active=true&closed=false&order=volume_24hr&ascending=false&limit=50"Fetch a Specific Event by Slug
Section titled “Fetch a Specific Event by Slug”Extract the slug from the Openfish frontend URL:
https://openfish.me/event/btc-100k-by-december ^ Slug: btc-100k-by-decembercurl "https://gamma.openfish.me/events?slug=btc-100k-by-december"Fetch Markets by Tag
Section titled “Fetch Markets by Tag”# Discover available tagscurl "https://gamma.openfish.me/tags"
# Filter events by tagcurl "https://gamma.openfish.me/events?tag_id=100381&active=true&closed=false&limit=20"Key Query Parameters
Section titled “Key Query Parameters”| Parameter | Description |
|---|---|
active | Filter by active status (true for live tradable events) |
closed | Filter by closed status (false to exclude resolved markets) |
order | Sort field: volume_24hr, volume, liquidity, start_date, end_date |
ascending | Sort direction (true or false, default false) |
limit | Results per page |
offset | Number of results to skip for pagination |
tag_id | Filter by category tag |
slug | Look up by URL slug |
Strategy 2: Gamma API Metadata for Rich Context
Section titled “Strategy 2: Gamma API Metadata for Rich Context”The Gamma API returns full event objects that embed their market arrays. This removes the need for separate market lookups and gives you metadata like descriptions, tags, resolution sources, and token IDs in a single response.
# Single request returns the event and all its marketscurl "https://gamma.openfish.me/events/125819"Each market object nested inside an event contains:
outcomesandoutcomePricesarraystokensarray with CLOB token IDsconditionIdfor market lookup and order routingenableOrderBookflag indicating CLOB availability
Rust SDK Example
Section titled “Rust SDK Example”use openfish_client_sdk::GammaClient;
#[tokio::main]async fn main() -> anyhow::Result<()> { let gamma = GammaClient::new("https://gamma.openfish.me");
// Fetch event with all nested markets let event = gamma.event_by_id("125819").await?;
println!("Event: {}", event.title); for market in &event.markets { println!(" Market: {}", market.question); println!(" Condition ID: {}", market.condition_id); println!(" Prices: {:?}", market.outcome_prices); println!(" Order book enabled: {}", market.enable_order_book); }
Ok(())}Strategy 3: WebSocket Streaming
Section titled “Strategy 3: WebSocket Streaming”For integrations that demand real-time data, connect to the market WebSocket. It delivers price-level deltas, top-of-book updates, trade events, and new-market notifications with no polling involved.
const ws = new WebSocket("wss://api.openfish.me/ws/market");
ws.addEventListener("open", () => { ws.send(JSON.stringify({ type: "subscribe", assets_ids: [ "71321045679252212594626385532706912750332728571942532289631379312455583992563", ], level: 2, initial_dump: false, }));});
ws.addEventListener("message", (message) => { if (message.data === "PING") { ws.send("PONG"); return; }
const event = JSON.parse(message.data); if (event.type === "price_change" || event.type === "best_bid_ask") { console.log(event.asset_id, event.best_bid, event.best_ask); }});Pagination
Section titled “Pagination”All list endpoints paginate with limit and offset:
# Page 1curl "https://gamma.openfish.me/events?active=true&closed=false&limit=50&offset=0"
# Page 2curl "https://gamma.openfish.me/events?active=true&closed=false&limit=50&offset=50"
# Page 3curl "https://gamma.openfish.me/events?active=true&closed=false&limit=50&offset=100"Keep incrementing offset by limit until the response returns fewer items than limit.
Choosing the Right Strategy
Section titled “Choosing the Right Strategy”| Strategy | Best For | Latency | Complexity |
|---|---|---|---|
| REST polling | Periodic snapshots, simple integrations | Seconds | Low |
| Gamma API metadata | Rich context, event-level views | Seconds | Low |
| World Cup topic | Game-first World Cup views | Cached seconds | Low |
| WebSocket streaming | Real-time dashboards, trading bots | Milliseconds | Medium |
Best Practices
Section titled “Best Practices”- Default to
active=true&closed=falseunless you specifically need resolved or historical markets. - Prefer
/browse/marketsfor Openfish-native app and agent market cards. - Use
/browse/topics/world-cup/gameswhen the user experience starts from World Cup dates and games. - Use Gamma events when you need rich imported metadata and event-level context.
- For trading bots, load an initial snapshot via REST, then switch to WebSocket streaming for live updates.
- Cache Gamma API responses and refresh on a schedule rather than hitting the API on every user interaction.
Next Steps
Section titled “Next Steps”- Market Data Overview — Full endpoint listing.
- Real-Time Markets — Crypto and stock real-time market behavior.
- WebSocket Overview — Real-time data streaming reference.