CostDepth API
Free, no API key, HTTPS, CORS enabled. The same numbers that power the calculator: live order books and hourly spread + slippage history for 17 crypto exchanges, BTC and ETH against USDT, spot and USDT-margined perpetuals. Machine-readable spec: /openapi.json (OpenAPI 3.1).
Basics
- Base URL
https://www.costdepth.io. Every endpoint is a plain GET; browsers can call it directly thanks toAccess-Control-Allow-Origin: *. - Books are sampled every 5 minutes and averaged per UTC hour; live endpoints are cached for 20 to 60 seconds at the edge.
- Fair use: please cache on your side. Around 60 requests a minute per IP is fine; there is nothing to gain from polling faster than every 5 minutes.
- A bad parameter returns HTTP 400 with
{"ok":false,"error":"..."}; the message names the allowed values. - Data is provided as-is, not financial advice. If you use it, please link to costdepth.io (see license).
Shared values
Exchange ids for ex: binance, bybit, okx, bitget, mexc, kucoin, bingx, htx, weex, gate, blofin, whitebit, ourbit, coinw, lbank, bitunix, hyperliquid. Spot is offered by 14 of them (binance, bybit, okx, bitget, mexc, kucoin, bingx, htx, weex, gate, whitebit, ourbit, coinw, lbank); BloFin, Bitunix and Hyperliquid are perpetual only. m is spot or perp, c is BTC or ETH.
Cost ladders (b for buy, s for sell) hold seven numbers, one per order size: $1k, $5k, $10k, $50k, $100k, $500k, $1M. Each is the spread + slippage of a market order of that size in basis points against the mid price (1 bp = 0.01%), worked out by walking the book. Trading fees are not included; null means the visible book could not fill that size.
GET /api/book
The current order book of one exchange, market and coin, trimmed to at least 20 levels per side and about $2.5M of depth. Sizes are in coins (contract books are converted). If the exchange cannot be reached, ok is false and last carries the last good stored ladder when it is under 15 minutes old; suspect: true marks a book that failed a sanity check.
| Parameter | Required | Allowed values |
|---|---|---|
ex | yes | exchange id |
m | yes | spot | perp (must be offered by ex) |
c | yes | BTC | ETH |
curl -s "https://www.costdepth.io/api/book?ex=binance&m=perp&c=BTC"{
"ok": true,
"book": {
"bids": [
[75355.5, 1.274],
[75355.4, 0.006],
[75355, 2.032]
],
"asks": [
[75355.6, 18.308],
[75356, 3.719],
[75356.1, 6.289]
],
"ts": 1793943148589
},
"ts": 1793943148589
}GET /api/ladders
One ladder per exchange that offers the market, the quickest way to rank venues for a size. live is false when a stored value stands in; t is the book time in milliseconds, or null when nothing recent exists.
| Parameter | Required | Allowed values |
|---|---|---|
m | yes | spot | perp |
c | yes | BTC | ETH |
curl -s "https://www.costdepth.io/api/ladders?m=perp&c=BTC"[
{
"id": "binance",
"live": true,
"t": 1793943149085,
"b": [0.007, 0.007, 0.007, 0.007, 0.007, 0.007, 0.007],
"s": [0.007, 0.007, 0.007, 0.007, 0.009, 0.31, 0.52]
},
{
"id": "bybit",
"live": true,
"t": 1793943149085,
"b": [0.007, 0.007, 0.007, 0.007, 0.007, 0.008, 0.411],
"s": [0.007, 0.185, 0.288, 0.371, 0.381, 0.679, 1.004]
}
]GET /api/history
Seven days of hourly averages for one exchange, keyed exchange:market:coin. Each row is [hour, buy ladder, sell ladder], oldest first, with the hour as YYYY-MM-DDTHH in UTC.
| Parameter | Required | Allowed values |
|---|---|---|
ex | yes | exchange id |
curl -s "https://www.costdepth.io/api/history?ex=binance"{
"binance:perp:BTC": [
[
"2026-11-06T00",
[0.007, 0.007, 0.007, 0.049, 0.105, 0.413, 0.793],
[0.007, 0.007, 0.007, 0.007, 0.007, 0.064, 0.283]
],
[
"2026-11-06T01",
[0.007, 0.007, 0.007, 0.007, 0.011, 0.317, 0.564],
[0.007, 0.007, 0.007, 0.01, 0.039, 0.31, 0.609]
]
]
}GET /api/history.csv
The same history as one CSV row per hour, exchange, market, coin, side and size, ready for a spreadsheet. Leave out ex for all exchanges.
| Parameter | Required | Allowed values |
|---|---|---|
ex | no | exchange id |
| Column | Meaning |
|---|---|
hour_utc | Start of the hour, UTC |
exchange, market, coin | Exchange id, spot or perp, BTC or ETH |
side | buy or sell |
size_usdt | Order size in USDT |
avg_slippage_bps | Average spread + slippage in basis points versus mid; fees not included |
samples | Samples that filled this size in that hour |
curl -s "https://www.costdepth.io/api/history.csv?ex=binance"hour_utc,exchange,market,coin,side,size_usdt,avg_slippage_bps,samples
2026-11-06T00:00Z,binance,spot,BTC,buy,1000,0.027,9
2026-11-06T00:00Z,binance,spot,BTC,buy,5000,0.067,9
2026-11-06T00:00Z,binance,spot,BTC,buy,10000,0.077,9GET /api/funding
The current funding rate of the BTC or ETH USDT perpetual, read from each exchange's public funding or premium-index endpoint. rate is a fraction per interval and rate_pct the same in percent; interval_h is the exchange's own interval, read from its API (8 hours on most venues, 1 hour on Hyperliquid). A long pays a positive rate each interval and a short receives it. When the exchange cannot be reached, the reading stored by the 5-minute sampler stands in (live: false, at most 30 minutes old). Leave out ex for every exchange.
| Parameter | Required | Allowed values |
|---|---|---|
ex | no | exchange id |
c | yes | BTC | ETH |
curl -s "https://www.costdepth.io/api/funding?ex=okx&c=BTC"{
"ex": "okx",
"coin": "BTC",
"ok": true,
"live": true,
"rate": 0.0000355487755354,
"rate_pct": 0.00355488,
"interval_h": 8,
"next_funding": "2026-11-06T08:00:00.000Z",
"ts": 1793946939286
}Estimated funding for a hold time, as the calculator does it: notional × rate × whole intervals in the hold time, paid by longs when the rate is positive. Funding changes every period, so this is an estimate at the current rate.
GET /api/health
A live check of every BTC book plus the sampler and storage. ok turns false only when storage fails, the last sample is over 20 minutes old, or three or more books fail; a single bad book or a failed funding feed is listed under warnings (and funding_failed). The human view is /status.
curl -s "https://www.costdepth.io/api/health"{
"ok": true,
"checked_at": "2026-11-06T05:32:30.589Z",
"storage": "blob",
"last_sample": "2026-11-06T05:30:50.625Z",
"sample_minutes": 5,
"exchanges": [
{
"name": "Binance",
"slug": "binance-fees",
"book_ok": true,
"books": {
"spot": {
"state": "ok",
"problem": null
},
"perp": {
"state": "ok",
"problem": null
}
},
"age_s": 100,
"fees_checked": "2026-11-06"
},
{
"name": "Bybit",
"slug": "bybit-fees",
"book_ok": true,
"books": {
"spot": {
"state": "ok",
"problem": null
},
"perp": {
"state": "ok",
"problem": null
}
},
"age_s": 100,
"fees_checked": "2026-11-05"
}
],
"problems": [],
"warnings": [],
"bad_books": 0,
"fees_being_verified": []
}Fee data
The API returns market depth and funding only. VIP 0 maker and taker rates (and VIP 1 to 3 where verified) come from each exchange's official fee page or its own API and are shown on the exchange pages with their check date, for example Binance (checked 6 Nov 2026) and OurBit (checked 6 Nov 2026). How the numbers are built is on the methodology page.
Data license
Free to use with attribution to costdepth.io (CC BY 4.0): copy, chart and republish the numbers, including commercially, with a link to costdepth.io. Data is provided as-is, without warranty, and is not financial advice. Data by Alex Wu.