# GET /perps/orderbook: $0.002 per call

Live order book for a perpetual futures market on Hyperliquid or dYdX: best bid and ask, spread in bps, USD depth within 10/50/100 bps of mid, and the average fill price and slippage of a market buy and sell of your size. Pass ?coin=ETH&sizeUsd=25000 (&venue=dydx).

- **Price:** $0.002 in USDC, the same on Base, Solana, Polygon, Arbitrum. Failed calls are never charged.
- **Free trial:** yes, 20 free calls a day from Claude, Cursor or any MCP client ([set-up](/mcp/setup)).
- **Answers cached for:** 5 s
- **Data sources:** Hyperliquid public info API; dYdX v4 public indexer
- **Lane:** Perpetual futures data ([OpenAPI](/openapi/perps.json))
- **Live health:** [status page](/status)

## Free sample

See an answer for the demo input first, free (no payment, 10 a minute): [https://aayatai.com/sample/perps-orderbook](/sample/perps-orderbook). It is a stored real answer when we have one, otherwise an example marked `"kind": "illustrative"`.

```bash
curl "https://aayatai.com/sample/perps-orderbook"
```

## 1. See the price (free)

Call it without paying: you get `402 Payment Required` and a `PAYMENT-REQUIRED` header with the exact price and where to pay.

```bash
curl -i "https://aayatai.com/perps/orderbook?coin=BTC&sizeUsd=100000&levels=3"
```

## 2. Pay and call (TypeScript)

```bash
npm install @x402/fetch @x402/evm viem
```

```ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A wallet used only by your agent, holding a little USDC on Base.
const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await pay("https://aayatai.com/perps/orderbook?coin=BTC&sizeUsd=100000&levels=3");
console.log(await res.json());
```

## 3. Or as an MCP tool

```ts
// MCP server: https://aayatai.com/mcp (Streamable HTTP). With the x402 MCP client (see /start):
const result = await client.callTool("perps-orderbook", {"coin":"BTC","sizeUsd":100000,"levels":3});
```

## Inputs

- `coin` **(required)** (string): Market symbol, e.g. BTC, ETH, SOL.
- `sizeUsd` (number; default `10000`): Order size in USD for the slippage estimate (100 to 10,000,000).
- `levels` (integer; default `10`): Price levels to return per side (0-20).
- `venue` (string; one of `auto`, `hyperliquid`, `dydx`; default `auto`): auto (default: Hyperliquid, or dYdX while Hyperliquid is unavailable), hyperliquid or dydx.
- `detail` (string; one of `full`, `brief`; default `full`): brief = key fields only (same price)

Bad inputs are rejected with HTTP 400 before any payment is asked for.

## Example answer

Example only: the shape of an answer, with placeholder addresses and made-up figures. It is not data about any real token or wallet; call the service (or its free sample) for real results.

```json
{
  "venue": "hyperliquid",
  "coin": "BTC",
  "asOf": "2026-09-29T23:30:00.000Z",
  "bookTime": "2026-09-29T23:28:06.140Z",
  "bestBid": 83715,
  "bestAsk": 83716,
  "mid": 83715.5,
  "spreadBps": 0.119,
  "depthUsd": {
    "bids": {
      "within10bps": 3830099,
      "within50bps": 3830099,
      "within100bps": 3830099
    },
    "asks": {
      "within10bps": 4457024,
      "within50bps": 4457024,
      "within100bps": 4457024
    }
  },
  "bookSpanBps": {
    "bids": 2.33,
    "asks": 2.33
  },
  "buy": {
    "sizeUsd": 100000,
    "filledUsd": 100000,
    "filledCoins": 1.19451479,
    "avgPx": 83716,
    "slippageBps": 0.06,
    "complete": true
  },
  "sell": {
    "sizeUsd": 100000,
    "filledUsd": 100000,
    "filledCoins": 1.19452906,
    "avgPx": 83715,
    "slippageBps": 0.06,
    "complete": true
  },
  "bids": [
    {
      "px": 83715,
      "sz": 5.49445
    },
    {
      "px": 83714,
      "sz": 0.83782
    },
    {
      "px": 83713,
      "sz": 1.45594
    }
  ],
  "asks": [
    {
      "px": 83716,
      "sz": 6.50975
    },
    {
      "px": 83717,
      "sz": 0.09
    },
    {
      "px": 83718,
      "sz": 0.0002
    }
  ],
  "attribution": "Data from Hyperliquid's public info API (api.hyperliquid.xyz)."
}
```

## Related

- [GET /perps/funding](/services/perps-funding) ($0.003): Perpetual futures funding rates from Hyperliquid and dYdX: the current hourly rate, 8-hour and annualised equivalents, premium, mark and oracle price and open i
- [GET /perps/open-interest](/services/perps-open-interest) ($0.002): Open interest on Hyperliquid or dYdX perpetual futures: contracts and USD value per market, share of the venue total, 24h volume, volume/OI, 24h price change an
- [GET /perps/markets](/services/perps-markets) ($0.003): Every perpetual futures market on Hyperliquid and dYdX side by side: which venues list each coin, price, open interest, 24h volume, max leverage and funding (ho

New here? [Getting started in 60 seconds](/start). All services: [Aayat AI](/).