Build a Liquidity Heatmap Using Mila-ex Order Books
December 26, 2025

Liquidity isn’t a number — it’s a shape
“Is this market liquid?” is a misleading question. What you really care about is: how much size can I execute at different price levels? That’s a heatmap problem, and the fastest way to build it is with standardized order book data.
The endpoints you need
- Depth snapshot: GET /api/v1/exchange/orderbook
- Recent completed trades: GET /api/v1/exchange/orderbook/complete
Order book request
GET https://api.milaex.com/api/v1/exchange/orderbook?exchange=binance&base_name=BTC"e_name=USDT
Header:x-api-key: YOUR_API_KEY
Interpreting the response
Mila-ex returns bids and asks in a consistent format (price/quantity/amount/count). That means you can reuse the same visualization logic across exchanges.
Simple heatmap bucket algorithm
A practical approach is to bucket levels by price step (e.g., $10) and sum amounts per bucket. Below is a compact JavaScript example you can plug into any charting library.
function bucketBook(levels, step) {
// levels: [{ price, quantity, amount, count }]
const buckets = new Map(); for (const lvl of levels) {
const bucket = Math.round(lvl.price / step) * step;
const prev = buckets.get(bucket) || 0;
buckets.set(bucket, prev \+ (lvl.amount || 0));
} return Array.from(buckets.entries())
.sort((a, b) =\> a[0] \- b[0])
.map(([price, amount]) =\> ({ price, amount }));
}async function fetchOrderbook() { const url = new URL("https://api.milaex.com/api/v1/exchange/orderbook"); url.searchParams.set("exchange", "binance"); url.searchParams.set("base_name", "BTC"); url.searchParams.set("quote_name", "USDT");
const res = await fetch(url, { headers: { "x-api-key": "YOUR_API_KEY" } });
if (\!res.ok) throw new Error(await res.text()); const json = await res.json();
return json.Data;
}fetchOrderbook().then(book =\> {
const bids = bucketBook(book.bids || [], 10);
const asks = bucketBook(book.asks || [], 10);
console.log({ bids, asks });
});Make it “trader useful” with completed trades
Depth shows supply/demand; prints show what actually executed. Pair the heatmap with the completed trades endpoint:
GET https://api.milaex.com/api/v1/exchange/orderbook/complete?exchange=binance&base_name=BTC"e_name=USDT
This lets you overlay buy/sell pressure and identify absorption zones.Operational tips
- Poll responsibly: order books are commonly limited to \~2 requests per 10 seconds.
- Visualize relative size: log-scale or quantile buckets often read better than linear color scales.
- Pick the right step size: tighter steps for liquid pairs, wider for thin pairs.
Related reading
- Understanding Order Book Depth and Liquidity
- OHLCV Candles for Backtesting (Guide)
- Real-Time Tickers Across Exchanges
- Rate Limits & Resilience for Trading Bots
Reference
See the full request/response models in the Mila-ex API Docs.