Skip to main content
For real-time books, use WebSockets.
async fn fetch_orderbook(
    req: OrderbookRequest,
) -> Result<Orderbook, OpenPxError>

Parameters

market_id
string
required
Native market ID.
outcome
string?
"Yes" or "No" (binary markets).
token_id
string?
Polymarket CLOB token. Takes precedence over outcome.

Returns

Orderbook with bids sorted high-to-low and asks low-to-high.
market_id
string
asset_id
string
bids
PriceLevel[]
asks
PriceLevel[]
last_update_id
u64?
timestamp
DateTime?
hash
string?

Example

use openpx::OrderbookRequest;

let book = ex.fetch_orderbook(OrderbookRequest {
    market_id: "KXBTC-25MAR14-T20000".into(),
    outcome: Some("Yes".into()),
    token_id: None,
}).await?;