> ## Documentation Index
> Fetch the complete documentation index at: https://goldrush.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# l2Book | Hyperliquid Info API

> Hyperliquid l2Book: fetch an aggregated Level-2 order book snapshot for a single coin - bids and asks as price, size, and order-count levels.

<CardGroup cols={2}>
  <Card title="Credit Cost"> 1 per call</Card>
  <Card title="Processing"> Realtime</Card>
</CardGroup>

The Hyperliquid info endpoint with `type: "l2Book"` is used to fetch an aggregated Level-2 order book snapshot for a single coin - bids and asks as price, size, and order-count levels.

<Tip>
  Estimate your monthly cost for this API using the [Pricing Calculator](/pricing-calculator?endpoint=%2Fapi-reference%2Fhyperliquid-info%2Fl2-book).
</Tip>

<Info>
  * Wire-equal to `POST api.hyperliquid.xyz/info` with `{"type": "l2Book", "coin": "..."}`.
  * Returns at most 20 levels per side.
  * For a continuous push stream instead of polling snapshots, subscribe to the <a href="https://goldrush.dev/docs/api-reference/hyperliquid-websocket/l2-book" target="_blank" rel="noopener noreferrer">WebSocket API `l2Book`</a> channel (optional wildcard `coin`) or the GoldRush-native <a href="https://goldrush.dev/docs/api-reference/hyperliquid-websocket/l2-book-diff" target="_blank" rel="noopener noreferrer">`l2BookDiff`</a> for incremental updates.
</Info>

Returns a point-in-time aggregated order book for one `coin`: two arrays of price levels (bids first, then asks), each level carrying the price, the total resting size at that price, and the number of orders comprising it. Use it for a one-shot depth snapshot, spread checks, or seeding a book before switching to a diff stream.

## Endpoint

```
POST https://hypercore.goldrushdata.com/info
Authorization: Bearer <GOLDRUSH_API_KEY>
Content-Type: application/json
```

## Request

<ParamField body="type" type="string" required default="l2Book">
  Always `"l2Book"`.
</ParamField>

<ParamField body="coin" type="string" required>
  The asset symbol, e.g. `"BTC"`. For HIP-3 markets use the deployer-prefixed form (e.g. `"xyz:GOLD"`); for spot use the pair symbol or `@<index>`.
</ParamField>

<ParamField body="nSigFigs" type="int">
  Number of significant figures to aggregate price levels to (`2`-`5`). Omit or pass `null` for full precision.
</ParamField>

<ParamField body="mantissa" type="int">
  Optional mantissa for price-level bucketing. Only valid when `nSigFigs` is `5`. Omit or pass `null` for the default.
</ParamField>

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://hypercore.goldrushdata.com/info \
    -H "Authorization: Bearer $GOLDRUSH_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "type": "l2Book",
      "coin": "BTC"
    }'
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch("https://hypercore.goldrushdata.com/info", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.GOLDRUSH_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      type: "l2Book",
      coin: "BTC",
    }),
  });

  const book = await response.json();
  const [bids, asks] = book.levels;
  ```

  ```python Python theme={null}
  import os, requests

  response = requests.post(
      "https://hypercore.goldrushdata.com/info",
      headers={"Authorization": f"Bearer {os.environ['GOLDRUSH_API_KEY']}"},
      json={"type": "l2Book", "coin": "BTC"},
  )

  book = response.json()
  bids, asks = book["levels"]
  ```
</CodeGroup>

## Response

A single JSON object. `levels` is a two-element array: element 0 is the bid side (descending price), element 1 is the ask side (ascending price). Each level is a `{px, sz, n}` object.

```json theme={null}
{
  "coin": "BTC",
  "time": 1780940795265,
  "levels": [
    [
      { "px": "63405.0", "sz": "4.43382", "n": 36 },
      { "px": "63404.0", "sz": "3.38588", "n": 44 }
    ],
    [
      { "px": "63406.0", "sz": "0.00347", "n": 3 },
      { "px": "63407.0", "sz": "0.00017", "n": 1 }
    ]
  ]
}
```

### Field descriptions

<Note>
  `px` and `sz` are returned as **decimal strings**, preserving upstream precision. Do not parse them as floats.
</Note>

<ResponseField name="coin" type="string">The asset the book is for - echoes the request `coin`.</ResponseField>
<ResponseField name="time" type="int">Snapshot timestamp in milliseconds since Unix epoch.</ResponseField>

<ResponseField name="levels" type="array<array<object>>">
  Two-element array: `levels[0]` are bids (sorted highest price first), `levels[1]` are asks (sorted lowest price first). Each side defaults to up to 20 aggregated levels.

  <Expandable title="level properties">
    <ResponseField name="px" type="string">Price of the level.</ResponseField>
    <ResponseField name="sz" type="string">Total resting size at this price.</ResponseField>
    <ResponseField name="n" type="int">Number of individual orders aggregated into this level.</ResponseField>
  </Expandable>
</ResponseField>

*Last reviewed: 2026-06-16*
