{"openapi":"3.1.0","info":{"title":"CostDepth API","version":"1.0.0","summary":"Free crypto exchange fee, spread and slippage data","description":"Live order books, perpetual funding rates and hourly spread + slippage history for 17 crypto exchanges (BTC and ETH, spot and USDT perpetual); history from a snapshot every 5 minutes. Free, no API key, HTTPS, CORS enabled. Data is provided as-is, not financial advice. Please link to costdepth.io if you use it.","contact":{"name":"CostDepth","url":"https://www.costdepth.io/developers","email":"alexwu@costdepth.io"},"license":{"name":"CC BY 4.0: free to use with attribution to costdepth.io","url":"https://www.costdepth.io/developers#license"}},"externalDocs":{"description":"Documentation","url":"https://www.costdepth.io/developers"},"servers":[{"url":"https://www.costdepth.io"}],"paths":{"/api/book":{"get":{"operationId":"getBook","summary":"Live order book for one exchange, market and coin","parameters":[{"name":"ex","in":"query","required":true,"description":"Exchange id. Spot is offered by: binance, bybit, okx, bitget, mexc, kucoin, bingx, htx, weex, gate, whitebit, ourbit, coinw, lbank.","schema":{"type":"string","enum":["binance","bybit","okx","bitget","mexc","kucoin","bingx","htx","weex","gate","blofin","whitebit","ourbit","coinw","lbank","bitunix","hyperliquid"]}},{"name":"m","in":"query","required":true,"description":"Market: spot or perp (USDT-margined perpetual).","schema":{"type":"string","enum":["spot","perp"]}},{"name":"c","in":"query","required":true,"description":"Coin, quoted in USDT.","schema":{"type":"string","enum":["BTC","ETH"]}}],"responses":{"200":{"description":"Book, or the last good stored ladder when the exchange cannot be reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BookResponse"}}}},"400":{"description":"Bad parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ladders":{"get":{"operationId":"getLadders","summary":"Spread + slippage ladder for every exchange in one market","parameters":[{"name":"m","in":"query","required":true,"description":"Market: spot or perp (USDT-margined perpetual).","schema":{"type":"string","enum":["spot","perp"]}},{"name":"c","in":"query","required":true,"description":"Coin, quoted in USDT.","schema":{"type":"string","enum":["BTC","ETH"]}}],"responses":{"200":{"description":"One entry per exchange offering the market","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Ladder"}}}}},"400":{"description":"Bad parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/history":{"get":{"operationId":"getHistory","summary":"Hourly spread + slippage history (7 days) for one exchange","parameters":[{"name":"ex","in":"query","required":true,"description":"Exchange id. Spot is offered by: binance, bybit, okx, bitget, mexc, kucoin, bingx, htx, weex, gate, whitebit, ourbit, coinw, lbank.","schema":{"type":"string","enum":["binance","bybit","okx","bitget","mexc","kucoin","bingx","htx","weex","gate","blofin","whitebit","ourbit","coinw","lbank","bitunix","hyperliquid"]}}],"responses":{"200":{"description":"Keyed by \"exchange:market:coin\"; each item is [hour (UTC, \"YYYY-MM-DDTHH\"), buy bps per ladder size, sell bps per ladder size], oldest first","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"type":"array","items":{"type":"array","prefixItems":[{"type":"string"},{"type":"array","minItems":7,"maxItems":7,"items":{"type":["number","null"]},"description":"Spread + slippage in basis points versus mid for each ladder size (1000, 5000, 10000, 50000, 100000, 500000, 1000000 USDT), fees not included; null = the visible book could not fill that size."},{"type":"array","minItems":7,"maxItems":7,"items":{"type":["number","null"]},"description":"Spread + slippage in basis points versus mid for each ladder size (1000, 5000, 10000, 50000, 100000, 500000, 1000000 USDT), fees not included; null = the visible book could not fill that size."}],"minItems":3,"maxItems":3}}}}}},"400":{"description":"Bad parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/history.csv":{"get":{"operationId":"getHistoryCsv","summary":"Hourly spread + slippage history as CSV","parameters":[{"name":"ex","in":"query","required":false,"description":"Exchange id. Spot is offered by: binance, bybit, okx, bitget, mexc, kucoin, bingx, htx, weex, gate, whitebit, ourbit, coinw, lbank.","schema":{"type":"string","enum":["binance","bybit","okx","bitget","mexc","kucoin","bingx","htx","weex","gate","blofin","whitebit","ourbit","coinw","lbank","bitunix","hyperliquid"]}}],"responses":{"200":{"description":"Columns: hour_utc, exchange, market, coin, side, size_usdt, avg_slippage_bps, samples","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Bad parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/funding":{"get":{"operationId":"getFunding","summary":"Current funding rate of the BTC or ETH USDT perpetual","description":"Read live from each exchange's public funding or premium-index endpoint (also sampled every 5 minutes as a fallback). A long pays a positive rate once per interval, a short receives it. Without ex, returns every exchange.","parameters":[{"name":"ex","in":"query","required":false,"description":"Exchange id. Leave out for all exchanges.","schema":{"type":"string","enum":["binance","bybit","okx","bitget","mexc","kucoin","bingx","htx","weex","gate","blofin","whitebit","ourbit","coinw","lbank","bitunix","hyperliquid"]}},{"name":"c","in":"query","required":true,"description":"Coin, quoted in USDT.","schema":{"type":"string","enum":["BTC","ETH"]}}],"responses":{"200":{"description":"One Funding object with ex, or an array of them without","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Funding"},{"type":"array","items":{"$ref":"#/components/schemas/Funding"}}]}}}},"400":{"description":"Bad parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/health":{"get":{"operationId":"getHealth","summary":"Live state of every BTC book, the sampler and storage","responses":{"200":{"description":"Health report","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}}},"components":{"schemas":{"Error":{"type":"object","required":["ok","error"],"properties":{"ok":{"const":false},"error":{"type":"string"}}},"Level":{"type":"array","prefixItems":[{"type":"number","description":"Price (USDT)"},{"type":"number","description":"Size (coin)"}],"minItems":2,"maxItems":2},"BookResponse":{"type":"object","required":["ok","ts"],"properties":{"ok":{"type":"boolean","description":"true = live book; false = see last / suspect"},"book":{"type":"object","properties":{"bids":{"type":"array","items":{"$ref":"#/components/schemas/Level"}},"asks":{"type":"array","items":{"$ref":"#/components/schemas/Level"}},"ts":{"type":"integer","description":"Fetch time, ms since epoch"}}},"suspect":{"type":"boolean","description":"The book failed a sanity check (crossed, thin, stale or off-market mid)"},"last":{"type":["object","null"],"properties":{"t":{"type":"integer"},"b":{"type":"array","minItems":7,"maxItems":7,"items":{"type":["number","null"]},"description":"Spread + slippage in basis points versus mid for each ladder size (1000, 5000, 10000, 50000, 100000, 500000, 1000000 USDT), fees not included; null = the visible book could not fill that size."},"s":{"type":"array","minItems":7,"maxItems":7,"items":{"type":["number","null"]},"description":"Spread + slippage in basis points versus mid for each ladder size (1000, 5000, 10000, 50000, 100000, 500000, 1000000 USDT), fees not included; null = the visible book could not fill that size."}},"description":"Last good stored ladder, at most 15 minutes old"},"ts":{"type":"integer","description":"ms since epoch"}}},"Ladder":{"type":"object","required":["id","live","t","b","s"],"properties":{"id":{"type":"string","enum":["binance","bybit","okx","bitget","mexc","kucoin","bingx","htx","weex","gate","blofin","whitebit","ourbit","coinw","lbank","bitunix","hyperliquid"]},"live":{"type":"boolean"},"suspect":{"type":"boolean"},"t":{"type":["integer","null"],"description":"Book time, ms since epoch; null = unavailable"},"b":{"type":"array","minItems":7,"maxItems":7,"items":{"type":["number","null"]},"description":"Spread + slippage in basis points versus mid for each ladder size (1000, 5000, 10000, 50000, 100000, 500000, 1000000 USDT), fees not included; null = the visible book could not fill that size."},"s":{"type":"array","minItems":7,"maxItems":7,"items":{"type":["number","null"]},"description":"Spread + slippage in basis points versus mid for each ladder size (1000, 5000, 10000, 50000, 100000, 500000, 1000000 USDT), fees not included; null = the visible book could not fill that size."}}},"Funding":{"type":"object","required":["ex","coin","ok"],"properties":{"ex":{"type":"string","enum":["binance","bybit","okx","bitget","mexc","kucoin","bingx","htx","weex","gate","blofin","whitebit","ourbit","coinw","lbank","bitunix","hyperliquid"]},"coin":{"type":"string","enum":["BTC","ETH"]},"ok":{"type":"boolean","description":"false = the exchange could not be read and no stored reading under 30 minutes exists"},"live":{"type":"boolean","description":"false = the last reading stored by the 5-minute sampler stands in"},"rate":{"type":"number","description":"Funding rate per interval as a fraction (0.0001 = 0.01%)"},"rate_pct":{"type":"number","description":"The same rate in percent"},"interval_h":{"type":"number","description":"Hours between funding payments (8 on most exchanges, 1 on Hyperliquid)"},"next_funding":{"type":["string","null"],"format":"date-time","description":"Next settlement, where the exchange gives it"},"ts":{"type":"integer","description":"Reading time, ms since epoch"},"error":{"type":"string"}}},"Health":{"type":"object","required":["ok","checked_at","storage","last_sample","exchanges","problems","warnings"],"properties":{"ok":{"type":"boolean"},"checked_at":{"type":"string","format":"date-time"},"storage":{"type":"string","enum":["blob","local","none"]},"last_sample":{"type":["string","null"],"format":"date-time"},"sample_minutes":{"type":"integer"},"exchanges":{"type":"array","items":{"type":"object"}},"problems":{"type":"array","items":{"type":"string"}},"warnings":{"type":"array","items":{"type":"string"}},"bad_books":{"type":"integer"},"fees_being_verified":{"type":"array","items":{"type":"string"}},"funding_failed":{"type":"array","items":{"type":"string"},"description":"Exchanges whose funding feed failed; a warning, not ok:false"},"vip_tiers_checking":{"type":"array","items":{"type":"string"},"description":"Exchanges whose VIP 1–3 tiers are not verified yet"}}}}}}