GET /market/{market_id}/orderbook
Returns the current orderbook snapshot for a market.
Request
Path Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
market_id | number | Yes | Market ID (e.g., 0 for BTC/USD) |
curl https://zo-mainnet.n1.xyz/market/0/orderbookResponse
{
"updateId": 1,
"asks": [
[]
],
"bids": [
[]
],
"asksSummary": {
"sum": 1,
"count": 1
},
"bidsSummary": {
"sum": 1,
"count": 1
}
}Response Fields
| Field | Type | Description |
|---|---|---|
updateId | number | Sequence number for tracking orderbook state |
bids | [price, size][] | Array of bid levels (buy orders), sorted by price descending |
asks | [price, size][] | Array of ask levels (sell orders), sorted by price ascending |
bidsSummary | object | Summary of all bids (sum: total size, count: number of levels) |
asksSummary | object | Summary of all asks (sum: total size, count: number of levels) |
Each level is a tuple of [price, size] where:
price: Limit pricesize: Total quantity at that price level
Example: Python
import requests
market_id = 0 # BTC/USD
response = requests.get(f"https://zo-mainnet.n1.xyz/market/{market_id}/orderbook")
orderbook = response.json()
print(f"Update ID: {orderbook['updateId']}")
print("\nTop 5 Bids:")
for price, size in orderbook["bids"][:5]:
print(f" ${price:,.1f} x {size:.4f}")
print("\nTop 5 Asks:")
for price, size in orderbook["asks"][:5]:
print(f" ${price:,.1f} x {size:.4f}")
# Calculate mid price
best_bid = orderbook["bids"][0][0] if orderbook["bids"] else 0
best_ask = orderbook["asks"][0][0] if orderbook["asks"] else 0
mid_price = (best_bid + best_ask) / 2
print(f"\nMid Price: ${mid_price:,.2f}")
# Summary stats
print(f"\nTotal Bid Size: {orderbook['bidsSummary']['sum']:.4f}")
print(f"Total Ask Size: {orderbook['asksSummary']['sum']:.4f}")Error Responses
| Status | Description |
|---|---|
| 404 | Market not found |
{
"market_id": 999
}Last updated on