Orderbook
Every orderbook endpoint is publicly accessible — no credentials, no wallet, no authentication. Use them to inspect market state before submitting orders.
Client Setup
Section titled “Client Setup”use openfish_client_sdk::clob::Client;
// Public client -- no auth neededlet client = Client::default(); // https://api.openfish.funREST base URL:
https://api.openfish.funGet the Orderbook
Section titled “Get the Orderbook”Returns the complete set of resting bid and ask levels for a given token.
use openfish_client_sdk::clob::types::request::OrderBookSummaryRequest;
let token_id = "TOKEN_ID".parse()?;let request = OrderBookSummaryRequest::builder().token_id(token_id).build();let book = client.order_book(&request).await?;
println!("Best bid: {:?}", book.bids.first());println!("Best ask: {:?}", book.asks.first());println!("Tick size: {:?}", book.tick_size);REST:
GET /book?token_id=TOKEN_IDResponse
Section titled “Response”{ "market": "0xbd31dc8a...", "asset_id": "52114319501245...", "timestamp": "2025-06-15T08:00:00Z", "bids": [ { "price": "0.48", "size": "1000" }, { "price": "0.47", "size": "2500" } ], "asks": [ { "price": "0.52", "size": "800" }, { "price": "0.53", "size": "1500" } ], "min_order_size": "5", "tick_size": "0.01", "neg_risk": false, "hash": "0xabc123..."}| Field | Description |
|---|---|
market | Condition ID of the market |
asset_id | Token ID |
bids | Buy orders sorted by price (highest first) |
asks | Sell orders sorted by price (lowest first) |
tick_size | Minimum price increment for this market |
min_order_size | Minimum order size |
neg_risk | Whether this is a multi-outcome (neg risk) market |
hash | Hash of the orderbook state for change detection |
Batch Orderbooks
Section titled “Batch Orderbooks”Pull orderbooks for several tokens in a single call:
POST /booksContent-Type: application/json
[ { "token_id": "TOKEN_A" }, { "token_id": "TOKEN_B" }]Prices
Section titled “Prices”Fetch the best available price on a particular side of the book.
use openfish_client_sdk::clob::types::{Side, request::PriceRequest};
let token_id = "TOKEN_ID".parse()?;
let buy_req = PriceRequest::builder().token_id(token_id).side(Side::Buy).build();let buy_price = client.price(&buy_req).await?;println!("Best ask (buy price): {}", buy_price.price);
let sell_req = PriceRequest::builder().token_id(token_id).side(Side::Sell).build();let sell_price = client.price(&sell_req).await?;println!("Best bid (sell price): {}", sell_price.price);REST:
# Best price for buying (lowest ask)GET /price?token_id=TOKEN_ID&side=BUY
# Best price for selling (highest bid)GET /price?token_id=TOKEN_ID&side=SELLBatch Prices
Section titled “Batch Prices”POST /pricesContent-Type: application/json
[ { "token_id": "TOKEN_A", "side": "BUY" }, { "token_id": "TOKEN_B", "side": "SELL" }]Midpoints
Section titled “Midpoints”The midpoint is calculated as the mean of the best bid and best ask. Openfish surfaces this number as the market’s implied probability.
use openfish_client_sdk::clob::types::request::MidpointRequest;
let token_id = "TOKEN_ID".parse()?;let request = MidpointRequest::builder().token_id(token_id).build();let midpoint = client.midpoint(&request).await?;println!("Midpoint: {}", midpoint.mid);REST:
GET /midpoint?token_id=TOKEN_IDResponse:
{ "mid": "0.50"}Batch Midpoints
Section titled “Batch Midpoints”POST /midpointsContent-Type: application/json
[ { "token_id": "TOKEN_A" }, { "token_id": "TOKEN_B" }]Spreads
Section titled “Spreads”The spread measures the gap between the best ask and the best bid. Narrower spreads generally signal deeper liquidity.
use openfish_client_sdk::clob::types::request::SpreadRequest;
let token_id = "TOKEN_ID".parse()?;let request = SpreadRequest::builder().token_id(token_id).build();let spread = client.spread(&request).await?;println!("Spread: {}", spread.spread);REST:
GET /spread?token_id=TOKEN_IDResponse:
{ "spread": "0.04"}Batch Spreads
Section titled “Batch Spreads”POST /spreadsContent-Type: application/json
[ { "token_id": "TOKEN_A" }, { "token_id": "TOKEN_B" }]Depth Levels
Section titled “Depth Levels”Full depth information comes from the GET /book response. Both sides contain arrays of price levels, each aggregating all resting size at that price:
- Bids: ordered from highest price down
- Asks: ordered from lowest price up
Each level includes:
| Field | Type | Description |
|---|---|---|
price | string | Price at this level |
size | string | Total resting size at this price |
The engine computes depth from bid_levels() and ask_levels() on the in-memory OrderBook, walking the BTreeMap to aggregate orders at each price point.
Last Trade Price
Section titled “Last Trade Price”Look up the most recent execution price and trade direction for a token.
use openfish_client_sdk::clob::types::request::LastTradePriceRequest;
let token_id = "TOKEN_ID".parse()?;let request = LastTradePriceRequest::builder().token_id(token_id).build();let last = client.last_trade_price(&request).await?;println!("Last: {} ({})", last.price, last.side);REST:
GET /last-trade-price?token_id=TOKEN_IDSummary of Endpoints
Section titled “Summary of Endpoints”| Endpoint | Method | Description |
|---|---|---|
/book | GET | Full orderbook for one token |
/books | POST | Batch orderbooks for multiple tokens |
/price | GET | Best price for one token and side |
/prices | POST | Batch prices |
/midpoint | GET | Midpoint for one token |
/midpoints | POST | Batch midpoints |
/spread | GET | Spread for one token |
/spreads | POST | Batch spreads |
/last-trade-price | GET | Most recent trade price |
Next Steps
Section titled “Next Steps”- Place Orders — Create and submit orders -> orders/create
- Matching Engine — How orders are matched -> matching-engine