Skip to content

Orderbook

Every orderbook endpoint is publicly accessible — no credentials, no wallet, no authentication. Use them to inspect market state before submitting orders.

use openfish_client_sdk::clob::Client;
// Public client -- no auth needed
let client = Client::default(); // https://api.openfish.fun

REST base URL:

https://api.openfish.fun

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:

Terminal window
GET /book?token_id=TOKEN_ID
{
"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..."
}
FieldDescription
marketCondition ID of the market
asset_idToken ID
bidsBuy orders sorted by price (highest first)
asksSell orders sorted by price (lowest first)
tick_sizeMinimum price increment for this market
min_order_sizeMinimum order size
neg_riskWhether this is a multi-outcome (neg risk) market
hashHash of the orderbook state for change detection

Pull orderbooks for several tokens in a single call:

Terminal window
POST /books
Content-Type: application/json
[
{ "token_id": "TOKEN_A" },
{ "token_id": "TOKEN_B" }
]

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:

Terminal window
# 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=SELL
Terminal window
POST /prices
Content-Type: application/json
[
{ "token_id": "TOKEN_A", "side": "BUY" },
{ "token_id": "TOKEN_B", "side": "SELL" }
]

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:

Terminal window
GET /midpoint?token_id=TOKEN_ID

Response:

{
"mid": "0.50"
}
Terminal window
POST /midpoints
Content-Type: application/json
[
{ "token_id": "TOKEN_A" },
{ "token_id": "TOKEN_B" }
]

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:

Terminal window
GET /spread?token_id=TOKEN_ID

Response:

{
"spread": "0.04"
}
Terminal window
POST /spreads
Content-Type: application/json
[
{ "token_id": "TOKEN_A" },
{ "token_id": "TOKEN_B" }
]

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:

FieldTypeDescription
pricestringPrice at this level
sizestringTotal 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.


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:

Terminal window
GET /last-trade-price?token_id=TOKEN_ID

EndpointMethodDescription
/bookGETFull orderbook for one token
/booksPOSTBatch orderbooks for multiple tokens
/priceGETBest price for one token and side
/pricesPOSTBatch prices
/midpointGETMidpoint for one token
/midpointsPOSTBatch midpoints
/spreadGETSpread for one token
/spreadsPOSTBatch spreads
/last-trade-priceGETMost recent trade price