# Crypto Order Book Depth: Liquidity and Slippage by Exchange (`scrapemint/crypto-order-book-depth`) Actor

Live spot order books from OKX, Gate, Bitget and KuCoin turned into the numbers a desk trades on: resting depth within 0.5, 1 and 2 per cent of mid, the slippage a given order size would pay, and which venue fills that size cheapest. Keyless, no browser.

- **URL**: https://apify.com/scrapemint/crypto-order-book-depth.md
- **Developed by:** [Ken M](https://apify.com/scrapemint) (community)
- **Categories:** Business, News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.00 / 1,000 order book rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Crypto Order Book Depth: Liquidity and Slippage by Exchange

A price quote tells you nothing about whether you can actually trade on it. This reads the **live spot order book on OKX, Gate, Bitget and KuCoin** and returns the numbers a desk trades on: how much is resting near the touch, what a given order size would really pay, and which venue fills that size cheapest.

No API key, no login, no browser.

### Modes

- **Depth** - one row per coin per venue: best bid and ask, the spread in basis points, and how much sits within **0.5, 1 and 2 per cent of mid** on each side, in coins and in quote currency, plus the book imbalance.
- **Slippage** - one row per coin per venue per order size: the **average fill price** a market order would get by walking the book, the **slippage in basis points** against mid, and the cash cost of that impact.
- **Compare** - one row per coin per order size: which venue fills it **cheapest**, how much worse the worst venue is, the full ranking, and which venues could not absorb the order at all.

### Example output

```json
{
  "mode": "slippage",
  "symbol": "BTC",
  "venue": "OKX",
  "instrument": "BTC-USDT",
  "midPrice": 64529.35,
  "spreadBasisPoints": 0.016,
  "side": "buy",
  "orderSizeUsd": 1000000,
  "filled": true,
  "averageFillPrice": 64546.94,
  "slippageBasisPoints": 2.726,
  "costVersusMidUsd": 272.6,
  "levelsConsumed": 63
}
```

### The thing that will bite you if you build this yourself

**The four venues do not publish the same amount of book.** Gate serves 1,000 levels a side, OKX 400, Bitget 150, KuCoin 100 on the public feed. Ask Bitget for 200 and it silently returns 150.

That difference swamps real liquidity differences. On a quiet BTC book, OKX's entire 400 levels can sit inside 0.5 per cent of mid, which means its "depth within 2 per cent" is really just its whole published book and the true figure is higher. Rank venues on those raw numbers and you will conclude the venue with the shortest feed is the least liquid, which is not what the data says.

So every depth row carries `band0_5PctFullyCovered`, `band1PctFullyCovered`, `band2PctFullyCovered` and a summary `allBandsFullyCovered`. Where a band is not fully covered the figure is a **floor, not a measurement**, and the row says so in `depthCaveat`.

The same rule governs slippage: **an order the visible book cannot absorb returns `filled: false` with a null price** and the fillable amount plus the shortfall, rather than the price of a partial fill dressed up as a complete one.

### Other things worth knowing

- **Snapshots are sequential, not atomic.** The books are read one after another, so a cross venue comparison spans a few seconds. Every compare row carries `snapshotSkewMs` so a tight gap can be judged against how far apart the readings were taken.
- **Best price and least slippage are two different rankings** and they disagree regularly. `bestVenue` is the best outright price you achieve; `lowestImpactVenue` is the smallest move against that venue's own mid. A venue can quote better and still show more impact. Both ship on every compare row.
- **Quantities are in the base asset** on all four venues, so notional is price times quantity throughout. Spot books only.
- **Binance and Bybit are not covered.** Both block Apify datacentre addresses. The four here are verified reachable.
- An unknown symbol is handled per venue: OKX answers **HTTP 200 with an error code in the body**, KuCoin answers **HTTP 200 with a null payload**, Gate and Bitget return 400. All four become a free note row naming the venue and the reason.

### Pricing

**$0.004 per row.** The first 2 rows of every run are free, and note rows (an unknown symbol, a venue that did not answer, a size no venue can fill) are never charged.

A depth snapshot of 3 coins across all 4 venues is 12 rows, or **$0.048**. A full slippage grid of 3 coins, 4 venues, 3 sizes and both sides is 72 rows, or **$0.29**. This is built to be scheduled: the value is in watching depth thin out before a move, not in one snapshot.

### Related actors

- **Crypto Liquidations Tracker** - the forced closeouts that eat this depth.
- **Crypto Funding Rates Tracker** and **Crypto Futures vs Spot** - positioning and carry on the same venues.
- **Crypto New Coin Listings Tracker: OKX, Gate, Bitget, KuCoin** - the listing event that creates a new book.

### How to run it via API

```bash
curl -X POST "https://api.apify.com/v2/acts/scrapemint~crypto-order-book-depth/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode":"compare","symbols":["BTC","ETH"],"orderSizesUsd":[100000,1000000]}'
```

# Actor input Schema

## `mode` (type: `string`):

depth = resting liquidity within 0.5, 1 and 2 per cent of mid on each venue. slippage = what a market order of a given size would actually pay. compare = which venue fills that size cheapest.

## `symbols` (type: `array`):

BTC, ETH, SOL, or a full pair such as BTC-USDT. Coins are matched against the quote asset below.

## `venues` (type: `array`):

okx, gate, bitget, kucoin. Empty returns all four. Binance and Bybit block datacentre addresses and cannot be covered.

## `quoteAsset` (type: `string`):

The asset the coin is priced in. USDT is listed on all four venues; other quotes exist on some venues only.

## `orderSizesUsd` (type: `array`):

Slippage and compare modes. Order sizes in quote currency, for example 10000, 100000, 1000000.

## `side` (type: `string`):

Slippage and compare modes. Buy walks the ask side, sell walks the bid side.

## `maxRows` (type: `integer`):

Cap on rows returned. Controls total cost.

## Actor input object example

```json
{
  "mode": "depth",
  "symbols": [
    "BTC",
    "ETH",
    "SOL"
  ],
  "venues": [
    "okx",
    "gate",
    "bitget",
    "kucoin"
  ],
  "quoteAsset": "USDT",
  "orderSizesUsd": [
    "10000",
    "100000",
    "1000000"
  ],
  "side": "both",
  "maxRows": 200
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "symbols": [
        "BTC",
        "ETH",
        "SOL"
    ],
    "venues": [
        "okx",
        "gate",
        "bitget",
        "kucoin"
    ],
    "quoteAsset": "USDT",
    "orderSizesUsd": [
        "10000",
        "100000",
        "1000000"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapemint/crypto-order-book-depth").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "symbols": [
        "BTC",
        "ETH",
        "SOL",
    ],
    "venues": [
        "okx",
        "gate",
        "bitget",
        "kucoin",
    ],
    "quoteAsset": "USDT",
    "orderSizesUsd": [
        "10000",
        "100000",
        "1000000",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("scrapemint/crypto-order-book-depth").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "symbols": [
    "BTC",
    "ETH",
    "SOL"
  ],
  "venues": [
    "okx",
    "gate",
    "bitget",
    "kucoin"
  ],
  "quoteAsset": "USDT",
  "orderSizesUsd": [
    "10000",
    "100000",
    "1000000"
  ]
}' |
apify call scrapemint/crypto-order-book-depth --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapemint/crypto-order-book-depth"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/32JIOSRdZWKyOEfO5/builds/NQofnyp6AruhPfty2/openapi.json
