# Get an L2 book snapshot for diff-stream bootstrap

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://api.g.alchemy.com/hypercore/v1/{apiKey}/l2-book-diff-snapshot

Retrieve aggregated L2 books at a common block height with each market's diff sequence.


Reference: https://www.alchemy.com/docs/data/hypercore/rest-api/hyper-core-data-api-endpoints/get-l-2-book-diff-snapshot

## Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| apiKey | string | Yes |  |

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://api.g.alchemy.com/hypercore/v1/string/l2-book-diff-snapshot \
  --header 'Content-Type: application/json' \
  --data '{
  "coins": [
    "string"
  ],
  "nSigFigs": "2",
  "mantissa": "2",
  "nLevels": "1"
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({coins: ['string'], nSigFigs: '2', mantissa: '2', nLevels: '1'})
};

fetch('https://api.g.alchemy.com/hypercore/v1/string/l2-book-diff-snapshot', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.g.alchemy.com/hypercore/v1/string/l2-book-diff-snapshot"

payload = {
    "coins": ["string"],
    "nSigFigs": "2",
    "mantissa": "2",
    "nLevels": "1"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.g.alchemy.com/hypercore/v1/string/l2-book-diff-snapshot"

	payload := strings.NewReader("{\n  \"coins\": [\n    \"string\"\n  ],\n  \"nSigFigs\": \"2\",\n  \"mantissa\": \"2\",\n  \"nLevels\": \"1\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://api.g.alchemy.com/hypercore/v1/string/l2-book-diff-snapshot")
  .header("Content-Type", "application/json")
  .body("{\n  \"coins\": [\n    \"string\"\n  ],\n  \"nSigFigs\": \"2\",\n  \"mantissa\": \"2\",\n  \"nLevels\": \"1\"\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.g.alchemy.com/hypercore/v1/string/l2-book-diff-snapshot");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"coins\": [\n    \"string\"\n  ],\n  \"nSigFigs\": \"2\",\n  \"mantissa\": \"2\",\n  \"nLevels\": \"1\"\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /{apiKey}/l2-book-diff-snapshot
method: POST
operation:
  operationId: get-l2-book-diff-snapshot
  summary: Get an L2 book snapshot for diff-stream bootstrap
  description: |
    Retrieve aggregated L2 books at a common block height with each market's diff sequence.
  parameters:
    - name: apiKey
      in: path
      required: true
      schema:
        type: string
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          required:
            - coins
          properties:
            coins:
              type: array
              minItems: 1
              items:
                type: string
              description: Markets to include in the snapshot.
            nSigFigs:
              type: integer
              enum:
                - 2
                - 3
                - 4
                - 5
              description: Significant-figure aggregation for price levels.
            mantissa:
              type: integer
              enum:
                - 2
                - 5
              description: Mantissa step. Valid only when nSigFigs is 5.
            nLevels:
              type: integer
              enum:
                - 1
                - 10
                - 20
                - 50
              description: Levels per side. Defaults to 20.
        examples:
          default:
            value:
              coins:
                - BTC
                - ETH
              nSigFigs: 5
              mantissa: 2
              nLevels: 20
  responses:
    '200':
      description: Successful response.
      content:
        application/json:
          schema:
            type: object
            required:
              - height
              - books
            properties:
              height:
                type: integer
                description: Block height reflected by every returned book.
              books:
                type: array
                items:
                  type: object
                  required:
                    - coin
                    - time
                    - levels
                    - seq
                  properties:
                    coin:
                      type: string
                      description: Market symbol.
                    time:
                      type: integer
                      format: int64
                      description: Unix timestamp in milliseconds.
                    levels:
                      type: array
                      minItems: 2
                      maxItems: 2
                      items:
                        type: array
                        items:
                          type: object
                          required:
                            - px
                            - sz
                            - 'n'
                          properties:
                            px:
                              type: string
                              description: Price as a decimal string.
                            sz:
                              type: string
                              description: Total size at the price level.
                            'n':
                              type: integer
                              description: Number of orders at the price level.
                      description: Two-element tuple of bids and asks.
                    seq:
                      type: integer
                      minimum: 0
                      description: Per-market l2BookDiff sequence at the snapshot height.
          examples:
            default:
              value:
                height: 123456
                books:
                  - coin: BTC
                    time: 1780000000000
                    levels:
                      - - px: '100000.0'
                          sz: '1.25'
                          'n': 3
                      - - px: '100001.0'
                          sz: '0.80'
                          'n': 2
                    seq: 42
```
