> ## 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.

# l2BookDiffSnapshot | Hyperliquid Info API

> Hyperliquid l2BookDiffSnapshot: fetch a full-depth L2 order book snapshot for one coin, with height, epoch, and seq to bootstrap the l2BookDiff2 stream.

> [card] Processing
>
> Realtime

The Hyperliquid info endpoint with `type: "l2BookDiffSnapshot"` is used to fetch a full-depth L2 order book snapshot for one coin, carrying the `height`, `epoch`, and per-coin `seq` needed to bootstrap and align the [`l2BookDiff2`](https://goldrush.dev/docs/api-reference/hyperliquid-websocket/l2-book-diff2) diff stream.

> [!NOTE]
>
> * GoldRush-native. `l2BookDiffSnapshot` is not a `POST api.hyperliquid.xyz/info` method - it is served only by the GoldRush endpoint.
> * **Bootstrap for [`l2BookDiff2`](https://goldrush.dev/docs/api-reference/hyperliquid-websocket/l2-book-diff2).** That WebSocket stream is diff-only; this endpoint provides the initial book to seed from, plus the `height`/`epoch`/`seq` to align the diffs onto it.
> * **Full depth.** Unlike the 20-level [`l2Book`](https://goldrush.dev/docs/api-reference/hyperliquid-info/l2-book) snapshot, this returns the complete resting book for the coin so your reconstruction starts from a complete state.
> * The snapshot already reflects every diff **up to and including** its own `height` (it is taken after that block is applied), so discard any diff at or below it.

Returns a point-in-time, full-depth aggregated order book for one `coin` - two arrays of price levels (bids first, then asks), each carrying price, resting size, and order count - together with the `height`, `epoch`, and per-coin `seq` that tie the snapshot to the `l2BookDiff2` stream.

## Endpoint

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

## Request

**type** `string` *required* (default: l2BookDiffSnapshot)

Always `"l2BookDiffSnapshot"`.

**coin** `string` *required*

The asset symbol, e.g. `"BTC"`. For HIP-3 markets use the deployer-prefixed form; for spot use the pair symbol or `@<index>`.

### Example

```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": "l2BookDiffSnapshot",
    "coin": "HYPE"
  }'
```

```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: "l2BookDiffSnapshot",
    coin: "HYPE",
  }),
});

const snap = await response.json();
const { height, epoch, seq } = snap;
const [bids, asks] = snap.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": "l2BookDiffSnapshot", "coin": "HYPE"},
)

snap = response.json()
height, epoch, seq = snap["height"], snap["epoch"], snap["seq"]
bids, asks = snap["levels"]
```

## 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": "HYPE",
  "time": 1786379674524,
  "height": 1105178185,
  "epoch": "466bf60f-bb7a-4591-89a3-a2660234fef5",
  "seq": 3669031,
  "levels": [
    [
      { "px": "54.208", "sz": "153.23", "n": 6 },
      { "px": "54.204", "sz": "48.81", "n": 1 }
    ],
    [
      { "px": "54.214", "sz": "12.34", "n": 2 },
      { "px": "54.216", "sz": "80.71", "n": 3 }
    ]
  ]
}
```

### Field descriptions

> [!NOTE]
>
> `px` and `sz` are returned as **decimal strings**, preserving upstream precision. Do not parse them as floats.

**coin** `string`

The asset the book is for - echoes the request `coin`.

**time** `int`

Snapshot timestamp in milliseconds since Unix epoch.

**height** `int`

HyperCore block height the snapshot was taken at. Discard any `l2BookDiff2` batch whose `block_height` is ≤ this value.

**epoch** `string`

Server generation (UUID). Must match the `epoch` on the `l2BookDiff2` batches you apply; a different `epoch` means the stream reset and you should re-fetch.

**seq** `int`

The per-coin sequence this snapshot is aligned to. The first `l2BookDiff2` diff you apply for this coin should have `prev_seq == seq`.

**levels** `array\<array\<object\>\>`

Two-element array: `levels[0]` are bids (highest price first), `levels[1]` are asks (lowest price first). Full depth.

**level properties**

**px** `string`

Price of the level.

**sz** `string`

Total resting size at this price.

**n** `int`

Number of individual orders aggregated into this level.

## Bootstrapping the l2BookDiff2 stream

Use this snapshot to seed a local book, then keep it current with the [`l2BookDiff2`](https://goldrush.dev/docs/api-reference/hyperliquid-websocket/l2-book-diff2) WebSocket stream:

1. Subscribe to `l2BookDiff2` for your coin(s) and start buffering `Updates`.
2. Fetch this snapshot; note `height`, `epoch`, and `seq`.
3. Drop any buffered batch whose `block_height` ≤ `height`.
4. Confirm each remaining batch's `epoch` equals this snapshot's `epoch` (else re-fetch).
5. Apply diffs in order - the first for the coin has `prev_seq == seq`.
6. Keep checking per-coin `prev_seq` continuity; on a gap or `epoch` change, re-fetch and re-bootstrap.

## Related endpoints

> [card] [l2Book](https://goldrush.dev/docs/api-reference/hyperliquid-info/l2-book.md)
>
> fetch an aggregated Level-2 order book snapshot for a single coin - bids and asks as price, size, and order-count levels.

> [card] [candleSnapshot](https://goldrush.dev/docs/api-reference/hyperliquid-info/candle-snapshot.md)
>
> fetch historical OHLCV candles for a coin and interval over a time window for charting and backtesting.

> [card] [allMids](https://goldrush.dev/docs/api-reference/hyperliquid-info/all-mids.md)
>
> fetch the current mid price for every actively traded asset in a single call.

> [card] [fundingHistory](https://goldrush.dev/docs/api-reference/hyperliquid-info/funding-history.md)
>
> fetch a coin’s historical funding rates and premiums over a time window for funding analytics and basis strategies.

See all Hyperliquid endpoints: [Overview hub](https://goldrush.dev/docs/goldrush-hyperliquid/overview.md) · [Info API reference](https://goldrush.dev/docs/goldrush-hyperliquid/info-api/overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.