# Market Data

## Get order book

### Connection

{% code title="URL" overflow="wrap" %}

```
/marketdata/v5/info?access_token={YOUR_ACCESS_TOKEN}
```

{% endcode %}

{% columns %}
{% column width="60%" %}
**`arguments`** `array`

The connection parameters.

In the first element, provide the `accountId` as a string.

In the second element, provide the `marketId` as a string.

**`invocationId`** `string`

The invocation identifier.

Must be unique and increase by 1 for each sent message.

**`target`** `string`

The stream name.

Specify `"Book"`.

**`type`** `int`

The operation type.

Set to `4` to indicate a subscription to the stream.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "arguments": [
    "67d0456f8c7b1108e4cf5d46",
    "cfd.eur_chf"
  ],
  "invocationId": "0",
  "target": "Book",
  "type": 4
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Message

{% columns %}
{% column width="60%" %}
**`type`** `string`

The operation type.

`2` indicates the streaming is in progress.

**`invocationId`** `string`

The invocation identifier. Same as in the request.

**`item`** `object`

The dataset object.

**`item.instrument`** `string`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`item.askTotalAmount`** `string`

The total ask amount.

**`item.bidTotalAmount`** `string`

The total bid amount.

**`item.asks`** `array of objects`

The array of ask price objects.

**`item.asks.price`** `string`

The price, in the quote asset.

**`item.asks.amount`** `string`

The total amount of the base asset available at a corresponding price level.

**`item.asks.total`** `string`

The total amount, in the quote asset, required to fully execute the orders at a corresponding price level.

**`item.bids`** `array of objects`

The array of bid price objects.

**`item.bids.price`** `string`

The price, in the quote asset.

**`item.bids.amount`** `string`

The total amount of the base asset available at a corresponding price level.

**`item.bids.total`** `string`

The total amount, in the quote asset, required to fully execute the orders at a corresponding price level.

**`item.version`** `string`

The order book version.

**`item.snapshot`** `boolean`

The data snapshot.

If `snapshot: true`, it indicates the message contains the full dataset. Subsequent messages with `snapshot: false` only include updates or changes since the initial snapshot.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "type": 2,
  "invocationId": "0",
  "item": {
    "instrument": "cfd.eur_chf",
    "askTotalAmount": "18700000",
    "bidTotalAmount": "19100000",
    "asks": [
      {
        "price": "0.93677",
        "amount": "5000000",
        "total": "4683850"
      },
      {
        "price": "0.93676",
        "amount": "0",
        "total": "0"
      },
      {
        "price": "0.93676",
        "amount": "0",
        "total": "0"
      }
    ],
    "bids": [
      {
        "price": "0.93654",
        "amount": "0",
        "total": "0"
      },
      {
        "price": "0.93654",
        "amount": "0",
        "total": "0"
      },
      {
        "price": "0.93655",
        "amount": "5000000",
        "total": "4682750"
      }
    ],
    "version": "12498",
    "snapshot": false
  }
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Get trading data

### Connection

{% code title="URL" overflow="wrap" %}

```
/marketdata/v5/info?access_token={YOUR_ACCESS_TOKEN}
```

{% endcode %}

{% columns %}
{% column width="60%" %}
**`arguments`** `array`

The connection parameters.

In the first element, provide the `accountId` as a string.

In the second element, provide a list of `marketIds` as an array of strings.

**`invocationId`** `string`

The invocation identifier.

Must be unique and increase by 1 for each sent message.

**`target`** `string`

The stream name.

Specify `"TradingData"`.

**`type`** `int`

The operation type.

Set to `4` to indicate a subscription to the stream.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "arguments": [
    "67d0456f8c7b1108e4cf5d46",
    [
      "spot.bnb_btc"
    ]
  ],
  "invocationId": "0",
  "target": "TradingData",
  "type": 4
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Message

{% columns %}
{% column width="60%" %}
**`type`** `string`

The operation type.

`2` indicates the streaming is in progress.

**`invocationId`** `string`

The invocation identifier. Same as in the request.

**`item`** `object`

The dataset object.

**`item.markets`** `array of objects`

The array of market objects.

**`item.markets.marketId`** `string`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`item.markets.type`** `string`

The market type.

Possible values:

* `Spot`
* `Cfd`
* `Perp`

**`item.markets.displayName`** `string`

The market ticker.

**`item.markets.fullName`** `string`

The market full name or description (optional).

**`item.markets.price`** `decimal string`

The current top-of-the-book price, in the quote asset.

**`item.markets.priceInRAT`** `decimal string`

The current top-of-the-book price, in conversion to the root asset of the platform.

**`item.markets.priceChange24hr`** `decimal string`

The price change over the last 24 hours, in percents.

This value is calculated as ((*Current price* – *Price 24h ago*) / *Current price*) × 100.

**`item.markets.priceChangeAbs24hr`** `decimal string`

The price change over the last 24 hours.

This value is calculated as *Current price* – *Price 24h ago*.

**`item.markets.highPrice24hr`** `decimal string`

The highest trade price over the last 24 hours.

**`item.markets.lowPrice24hr`** `decimal string`

The lowest trade price over the last 24 hours.

**`item.markets.markPrice`** `decimal string`

*Applicable to Perpetual markets only.*

The mid-spread price, in conversion to RAT.

**`item.markets.fundingRate`** `decimal string`

*Applicable to Perpetual markets only.*

The current funding rate.

**`item.snapshot`** `boolean`

The data snapshot.

If `snapshot: true`, it indicates the message contains the full dataset. Subsequent messages with `snapshot: false` only include updates or changes since the initial snapshot.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "type": 2,
  "invocationId": "0",
  "item": {
    "markets": [
      {
        "marketId": "cfd.eur_chf",
        "type": "Cfd",
        "displayName": "cfd.eur_chf",
        "fullName": "",
        "price": "0.93586",
        "priceInRAT": "1",
        "priceChange24hr": "-0.0006",
        "priceChangeAbs24hr": "-0.00049",
        "highPrice24hr": "0.93695",
        "lowPrice24hr": "0.93134",
        "markPrice": null,
        "fundingRate": null
      }
    ],
    "snapshot": false
  }
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Get top of the book

### Connection

{% code title="URL" overflow="wrap" %}

```
/marketdata/v5/info?access_token={YOUR_ACCESS_TOKEN}
```

{% endcode %}

{% columns %}
{% column width="60%" %}
**`arguments`** `array`

The connection parameters.

In the first element, provide the `accountId` as a string.

In the second element, provide a list of `marketIds` as an array of strings.

**`invocationId`** `string`

The invocation identifier.

Must be unique and increase by 1 for each sent message.

**`target`** `string`

The stream name.

Specify `"Tob"`.

**`type`** `int`

The operation type.

Set to `4` to indicate a subscription to the stream.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "arguments": [
    "67d0456f8c7b1108e4cf5d46",
    [
      "spot.eth_usdt"
    ]
  ],
  "invocationId": "0",
  "target": "Tob",
  "type": 4
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Message

{% columns %}
{% column width="60%" %}
**`type`** `string`

The operation type.

`2` indicates the streaming is in progress.

**`invocationId`** `string`

The invocation identifier. Same as in the request.

**`item`** `object`

The dataset object.

**`item.markets`** `array of objects`

The array of market objects.

**`item.markets.marketId`** `string`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`item.markets.ask`** `decimal string`

The top-of-the-book ask price.

**`item.markets.bid`** `decimal string`

The top-of-the-book bid price.

**`item.snapshot`** `boolean`

The data snapshot.

If `snapshot: true`, it indicates the message contains the full dataset. Subsequent messages with `snapshot: false` only include updates or changes since the initial snapshot.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "type": 2,
  "invocationId": "0",
  "item": {
    "markets": [
      {
        "marketId": "spot.eth_usdt",
        "ask": "2483.82",
        "bid": "2483.81"
      }
    ],
    "snapshot": false
  }
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Get trading chart

### Connection

{% code title="URL" overflow="wrap" %}

```
/marketdata/v5/info?access_token={YOUR_ACCESS_TOKEN}
```

{% endcode %}

{% columns %}
{% column width="60%" %}
**`arguments`** `array`

The connection parameters.

In the first element, provide the `accountId` as a string.

In the second element, provide the `marketId` and `timescale` as a string.

**`invocationId`** `string`

The invocation identifier.

Must be unique and increase by 1 for each sent message.

**`target`** `string`

The stream name.

Specify `"Chart"`.

**`type`** `int`

The operation type.

Set to `4` to indicate a subscription to the stream.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "arguments": [
    "67d0456f8c7b1108e4cf5d46",
    "cfd.eth_eur@15m"
  ],
  "invocationId": "0",
  "target": "Chart",
  "type": 4
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Message

{% columns %}
{% column width="60%" %}
**`type`** `string`

The operation type.

`2` indicates the streaming is in progress.

**`invocationId`** `string`

The invocation identifier. Same as in the request.

**`item`** `object`

The dataset object.

**`item.instrument`** `string`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`item.low`** `decimal string`

The lowest base asset price within the specified time interval.

**`item.high`** `decimal string`

The highest base asset price within the specified time interval.

**`item.open`** `decimal string`

The base asset price at the beginning of the specified time interval.

**`item.close`** `decimal string`

The base asset price at the end of the specified time interval.

**`item.start`** `dateTime`

The beginning of the specified time interval, in ISO 8601 format.

**`item.end`** `dateTime`

The end of the specified time interval, in ISO 8601 format.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "type": 2,
  "invocationId": "0",
  "item": {
    "instrument": "cfd.eth_eur",
    "low": "2240.88",
    "high": "2270.29",
    "open": "2265.63",
    "close": "2255.99",
    "start": "2025-05-21T15:30:00Z",
    "end": "2025-05-21T15:45:00Z"
  }
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Get market summary

### Connection

{% code title="URL" overflow="wrap" %}

```
/marketdata/v5/info?access_token={YOUR_ACCESS_TOKEN}
```

{% endcode %}

{% columns %}
{% column width="60%" %}
**`arguments`** `array`

The connection parameters.

In the first element, provide the `accountId` as a string.

In the second element, provide a list of `marketIds` as an array of strings.

**`invocationId`** `string`

The invocation identifier.

Must be unique and increase by 1 for each sent message.

**`target`** `string`

The stream name.

Specify `"Summary"`.

**`type`** `int`

The operation type.

Set to `4` to indicate a subscription to the stream.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "arguments": [
    "67d0456f8c7b1108e4cf5d46",
    [
      "cfd.eur_chf"
    ]
  ],
  "invocationId": "0",
  "target": "Summary",
  "type": 4
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Message

{% columns %}
{% column width="60%" %}
**`type`** `string`

The operation type.

`2` indicates the streaming is in progress.

**`invocationId`** `string`

The invocation identifier. Same as in the request.

**`item`** `object`

The dataset object.

**`item.items`** `array of objects`

The array of data objects.

**`item.items.marketId`** `string`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`item.items.last`** `decimal string`

The price of the last trade.

**`item.items.high24hr`** `decimal string`

The highest trade price over the last 24 hours.

**`item.items.low24hr`** `decimal string`

The lowest trade price over the last 24 hours.

**`item.items.percentChange`** `decimal string`

The price change over the last 24 hours, in percents.

This value is calculated as ((*Current price* – *Price 24h ago*) / *Current price*) × 100.

**`item.snapshot`** `boolean`

The data snapshot.

If `snapshot: true`, it indicates the message contains the full dataset. Subsequent messages with `snapshot: false` only include updates or changes since the initial snapshot.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "type": 2,
  "invocationId": "0",
  "item": {
    "items": [
      {
        "marketId": "cfd.eur_chf",
        "last": "0.93597",
        "high24hr": "0.93695",
        "low24hr": "0.93134",
        "percentChange": "-0.02"
      }
    ],
    "snapshot": false
  }
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}


---

# 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://api-docs.b2trader.b2broker.com/websocket-api/market-data.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.
