# Orderbook

## Stream order blocks in certain orderbooks in Standard spot exchange

### ✅ Request

{% tabs %}
{% tab title="Subscription" %}
{% code title="Subscription" %}

```json
{
  "id": 1,
  "method": "spot.orderbook.subscribe.pairs",
  "params": {
    "books": [{
      "pair": "ETH/USDC",
      "step": "0.1"
    },
    {
      "pair": "WBTC/USDT",
      "step": "0.01"
    }]
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Unsubscription" %}
{% code title="Unsubscription" %}

```json
{
  "id": 1,
  "method": "spot.orderbook.unsubscribe.pairs",
  "params": {
    "books": [{
      "pair": "ETH/USDC",
      "step": "0.1",  
    },
    {
      "pair": "WBTC/USDT",
      "step": "0.01"
    }]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📤 Response

{% tabs %}
{% tab title="Success" %}
{% code title="Success" %}

```json
{
  "result": null,
  "id": 1
}
```

{% endcode %}
{% endtab %}

{% tab title="Error" %}
{% code title="Error" %}

```json
{
  "code": 1,
  "msg": "Internal Error: {error}"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 📡 Streamed Data Format

{% code title="Order Block Stream" %}

```json
[
  "spotOrderBlock" // eventId
  true,            // isBid (buy order)
  3142.75,         // price
  1.5,             // baseVolume (ETH)
  4714.13,         // quoteVolume (USDC)
  2,               // scale
  1713659500       // timestamp
]
```

{% endcode %}

### 📄 Field Descriptions

| Index | Field         | Type      | Description                              |
| ----- | ------------- | --------- | ---------------------------------------- |
| 0\`   | `eventId`     | `string`  | Unique event identifier                  |
| 1     | `isBid`       | `boolean` | `true` for bid, `false` for ask          |
| 2     | `price`       | `float`   | Price of the update                      |
| 3     | `baseVolume`  | `float`   | Volume in base token                     |
| 4     | `quoteVolume` | `float`   | Volume in quote token                    |
| 5     | `scale`       | `float`   | Decimal scale of the price or bucket     |
| 6     | `timestamp`   | `integer` | UNIX timestamp of the event (in seconds) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.standard.im/apps/spot/for-developers/websocket-streams/orderbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
