> For the complete documentation index, see [llms.txt](https://guide.traderevolution.com/traderevolution-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.traderevolution.com/traderevolution-api/traderevolution-apis/client-api/market-data.md).

# Market data

This API part grants access to market data

This section includes several endpoints that serve different purposes:&#x20;

<mark style="color:blue;">`GET`</mark>`/depth` - is used to get a current depth of the market for the instrument.&#x20;

<mark style="color:blue;">`GET`</mark>`/history` - request for history bars.&#x20;

<mark style="color:blue;">`GET`</mark>`/quotes` - get the best bid and best ask of the instrument.&#x20;

<mark style="color:blue;">`GET`</mark>`/trades` - get the last trade price on the market.&#x20;

<mark style="color:blue;">`GET`</mark>`/dailyBar` – request for the latest daily bar.&#x20;

<mark style="color:blue;">`GET`</mark>`/crossRates` - request currency cross rates.

All methods must include `tradableInstrumentId`, which can be received via <mark style="color:blue;">`GET`</mark>`/accounts /{accountId}/instruments`, and `accountId`.

{% hint style="success" %}
A full list of available methods and their parameters can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Market%20data>
{% endhint %}

## Get daily bar

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/dailyBar`

This method allows you to request the current (latest) *day bar*. Please note that you should specify the bar type in the query, i.e. ask, bid, or trade (last). Also, the `tradableInstrumentId` should be specified, it can be found via <mark style="color:blue;">`GET`</mark>`/accounts /{accountId}/instruments` method.&#x20;

**Query**

<table><thead><tr><th width="301">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountId*</code></td><td>integer</td><td>Account identifier. </td></tr><tr><td><code>barType*</code></td><td>string</td><td>Defines the OHCL data source. Available values: <code>ASK</code>, <code>BID</code>, <code>TRADE</code>.</td></tr><tr><td><code>tradableInstrumentId*</code> </td><td>integer</td><td>Identifier of the instrument that is used for trading purposes. </td></tr></tbody></table>

**CURL (for ASK bar)**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/dailyBar?accountId=3243563&barType=ASK&tradableInstrumentId=11681" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0iLCJhdWQiOi...ODBzw6eluS4T_lmGe4r-TM6XAHoddR3PRuR0vG5oQmia3xxFAwVkchrmor1yLy-MKQCMiK3QqVjPJmQYsbjhl7OA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "o": 3418.42,
    "h": 3516.66,
    "l": 3405.01,
    "p": 3395.73,
    "v": null
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

As a result, you will get a data set in the response, which includes Open, High, Low, Previous close price and Volume.&#x20;

Standard errors can be received as well. If some data is absent, the <mark style="color:red;">`null`</mark> value will be returned (see Volume in the response).&#x20;

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Market%20data/getDailyBar>
{% endhint %}

## Market depth

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/depth`

This method allows requesting the current **market depth info** (order book) for the selected instrument by its `tradable ID`*,* which can be found via <mark style="color:blue;">`GET`</mark>`/accounts /{accountId}/instruments`.&#x20;

**Query**

<table><thead><tr><th width="279">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountId*</code></td><td>integer</td><td>Account identifier. </td></tr><tr><td><code>tradableInstrumentId*</code> </td><td>integer</td><td>Identifier of the instrument that is used for trading purposes. </td></tr></tbody></table>

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/depth?accountId=3243563&tradableInstrumentId=11281" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTR...GvI0oWA51Y3EprH7gdBYpM81SCborh6UCYIkNZJP_q4q8IyxfVqeK-KqCAg2g92VHlSMjJqT-2ZjiOjC37PBkYsWzuswj7jRe6Q"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "asks": [
      [
        211.55,
        10
      ],
      [
        211.56,
        201
      ],
      [
        211.57,
        2
      ],
      [
        211.59,
        300
      ],
      [
        211.6,
        736
      ]
    ],
    "bids": [
      [
        211.37,
        32
      ],
      [
        211.4,
        59
      ],
      [
        211.42,
        200
      ],
      [
        211.45,
        50
      ],
      [
        211.47,
        1838
      ]
    ]
  }
}
```

{% endtab %}
{% endtabs %}

The response will contain current bids and asks as well as the size value for each row. The info can be requested for a certain instrument once at a time.  Standard errors can be received as well.&#x20;

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Market%20data/getDepth>
{% endhint %}

## Historical data

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/history`

This method allows you to request specific historical data for the selected instrument (by its tradable ID), which can be found via <mark style="color:blue;">`GET`</mark>`/accounts/{accountId}/instruments`.&#x20;

Please note that the time for bars ≥ 1D (daily, weekly, monthly) will be set to 00:00 in UTC timezone.&#x20;

{% hint style="warning" %}
Note that QH (quote history) node is required for the Client API.
{% endhint %}

All the parameters in the table below are required:

**Query**

<table><thead><tr><th width="270">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountId*</code></td><td>integer</td><td>This parameter specifies the identifier of the account for which the history is requested.</td></tr><tr><td><code>from*</code></td><td>integer</td><td>Specifies the Unix timestamp in milliseconds (UTC) for the leftmost required bar, inclusive.</td></tr><tr><td><code>resolution*</code></td><td>string</td><td>Parameter defines the symbol resolution, with possible values: <code>daily (1D)</code>, <code>weekly (1W)</code>, <code>monthly (1M)</code>, <code>hourly (1H, 4H)</code>, and intra-day resolutions such as <code>minutes (1m, 5m, 15m, 30m)</code></td></tr><tr><td><code>to*</code></td><td>integer</td><td><p>Parameter specifies the Unix timestamp in milliseconds (UTC) for the rightmost required bar.</p><p>The <code>to</code> parameter represents the upper time boundary: if it falls inside a bar interval, that bar is returned but cut at the specified <code>to</code> timestamp (see examples below).</p></td></tr><tr><td><code>tradableInstrumentId*</code></td><td>integer</td><td>The identifier of the instrument for which the history is requested.</td></tr><tr><td><code>sortOrder</code></td><td>string</td><td><p>Defines the sorting order of the returned bars. </p><p>Possible values:</p><ul><li><code>ASC</code> - bars are returned from oldest to newest;</li><li><code>DESC</code> - bars are returned from newest to oldest.</li></ul><p>The parameter is case-insensitive.</p></td></tr></tbody></table>

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/history?accountId=3243753&from=1704067200000&resolution=1D&to=1722211200000&tradableInstrumentId=922" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiIxYWU0YmM5NS1lMDM4LTRlNmYtOTMxOC01Z1NiJ9.eyJzdWIiOiJpcnluYW0iL…CbSgWOtt5Rc3vqIRXPCBjq-cMu-TsmQPRdVniG77HQEjfn1OXJpRRX-eFAMUeQ3vfuG_jUE_OmjPLl4Sma_Q"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "barDetails": [
      {
        "t": 1704067200000,
        "o": 1.1038,
        "h": 1.1077,
        "l": 1.091,
        "c": 1.1037,
        "v": 9491
      },
      {
        "t": 1704153600000,
        "o": 1.10366,
        "h": 1.10434,
        "l": 1.09343,
        "c": 1.094,
        "v": 230184
      },
      {
        "t": 1722211200000,
        "o": 1.08525,
        "h": 1.087,
        "l": 1.0821,
        "c": 1.08234,
        "v": 77046
      }
    ]
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

The response object for this method contains detailed historical data for the specified instrument over the requested period. Each entry in the barDetails array represents a single bar, including properties such as the Timestamp of the bar in milliseconds (UTC), Open, High, Low, and Close prices + Volume.&#x20;

Bars are returned for the time interval \[`from`, `to`). Also note that the rightmost bar may not be full and is cut to the specified Unix timestamp.&#x20;

{% hint style="warning" %}
The request is subject to maximum allowed time range validation depending on the selected resolution. If the requested period exceeds the configured limit for the resolution group, the request will be rejected with an error response.

For example, for `1H` resolution the limit is `1 year`. Therefore, a request like `from: 2020-01-01` to `to: 2026-01-01` will be rejected because the requested range exceeds the allowed period.
{% endhint %}

For better understanding see examples below:

**Example 1 (Hourly bar with partial minutes):**

* `resolution`: 1H
* `from`: 1769612400000 → 17:00
* `to`: 1769613008877 → 17:10

Response:

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "barDetails": [
      {
        "t": 1769612400000,
        "o": 6.02,
        "h": 9.13,
        "l": 1.04,
        "c": 8.62,
        "v": 5191651
      }
    ]
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

In the response, the 1H bar starting at 17:00 is aggregated from minute bars in the interval **17:00, 17:01... → 17:09**.

**Example 2 (Multiple hourly bars):**

* `resolution`: 1H
* `from`: 1769605200000 → 13:00
* `to`: 1769616000000 → 16:00

Response:

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "barDetails": [
      {
        "t": 1769605200000,
        "o": 2.03,
        "h": 9.95,
        "l": 1.13,
        "c": 7.3,
        "v": 27210238
      },
      {
        "t": 1769608800000,
        "o": 9.23,
        "h": 9.53,
        "l": 1.2,
        "c": 8.5,
        "v": 29378204
      },
      {
        "t": 1769612400000,
        "o": 6.02,
        "h": 9.96,
        "l": 1.04,
        "c": 3.45,
        "v": 23842191
      }
    ]
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

In the response, there are 3 hourly bars:

* 13:00 (1769605200000) → aggregated from minute bars 13:00–13:59;
* 14:00 (1769608800000) → aggregated from minute bars 14:00–14:59;
* 15:00 (1769612400000) → aggregated from minute bars 15:00–15:59.

The 16:00 hourly bar is not included, because `to = 16:00` is **exclusive**. Each bar’s `t` corresponds to the start of the aggregation period. Aggregation always happens from all minute bars within the hour.

Note that possible errors include receiving a `no_data` status code if there is no data in the requested period. If there is no data in the requested period, but there is data in the previous period, the status code will be set to `no_data` and the nb property to UNIX timestamp of the next available bar behind the range.

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Market%20data/getHistory>
{% endhint %}

## Quotes

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/quotes`

This method allows you to get the current prices for the selected instrument (by its tradable ID). This ID can be found via the <mark style="color:blue;">`GET`</mark>`/accounts/{accountId}/instruments` request. Note that all the parameters in the table below are required:

**Query**

<table><thead><tr><th width="265">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountId*</code></td><td>integer</td><td>Specifies the identifier of the account.</td></tr><tr><td><code>tradableInstrumentId*</code></td><td>integer</td><td>Specifies the identifier of the instrument for which quotes are requested.</td></tr></tbody></table>

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/quotes?accountId=3243753&tradableInstrumentId=922" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiIxYWU0YmM5NS1lMDM4…l7L73fdi1g30RMXVK52LoNd62uFbmRdtjxMaDYcZ2x4Ym_HV9jsgrU4XCKfDTt8Q542n9NuJg"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "ap": 1.08286,
    "bp": 1.08281,
    "as": 1,
    "bs": 1
  }
}
```

{% endtab %}
{% endtabs %}

The response includes: `ap` - Ask price, `bp` - Bid price, `as` - Ask size, and `bs` - Bid size.&#x20;

Standard errors can also be received, and if any data is absent, the <mark style="color:red;">`null`</mark> value will be returned.

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Market%20data/getQuotes>
{% endhint %}

## Get last bar

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/lastBar`

This method allows you to request the latest daily bar (current OHLCV) for a given instrument, along with the previous close price and the previous bar’s date. The following parameters from the table below are required:

**Query**

<table><thead><tr><th width="268">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountId*</code></td><td>integer</td><td>Specifies the identifier of the account.</td></tr><tr><td><code>tradableInstrumentId*</code></td><td>integer</td><td>Specifies the identifier of the instrument for which the trades history is requested.</td></tr><tr><td><code>barType*</code></td><td>string</td><td>Defines the OHCL data source. Available values are: <em>BID</em>, <em>TRADE</em>, <em>ASK.</em></td></tr></tbody></table>

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/lastBar?accountId=146696&tradableInstrumentId=330017&barType=ASK" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiIxYWU0YmM5…73fdi1g30RMXVK52LoNd62uFbmRdtjxMaDYcZ2x4Ym_HV9jsgrU4XCKfDTt8Q542n9NuJg"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "o": 215.1,
    "h": 215.6,
    "l": 214.8,
    "c": 215.53,
    "v": 375837,
    "t": 107,
    "dt": 1753736400,
    "pc": 221.9,
    "pdt": 1753560000
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

If there is **no bar for today** (e.g., non-trading day or session not started), current bar fields will be null, but previous bar data will still be returned:

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "o": null,
    "h": null,
    "l": null,
    "c": null,
    "v": null,
    "t": null,
    "dt": null,
    "pc": 221.9,
    "pdt": 1753560000
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

The response for this method includes the Open (o), High (h), Low (l), Close (c) prices, Volume (v), Number of Ticks (t), and the Timestamp (dt) of the current bar, as well as the Previous Close (pc) and Previous Bar Timestamp (pdt).

## Trades

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/trades`

This method allows you to retrieve trade operations for the selected instrument by its tradable ID, which can be found via <mark style="color:blue;">`GET`</mark>`/accounts/{accountId}/instruments`. Note that all parameters from the table below are required:

**Query**

<table><thead><tr><th width="268">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountId*</code></td><td>integer</td><td>Specifies the identifier of the account.</td></tr><tr><td><code>tradableInstrumentId*</code></td><td>integer</td><td>Specifies the identifier of the instrument for which the trades history is requested.</td></tr></tbody></table>

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/trades?accountId=3243563&tradableInstrumentId=922" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiIxYWU0YmM5…73fdi1g30RMXVK52LoNd62uFbmRdtjxMaDYcZ2x4Ym_HV9jsgrU4XCKfDTt8Q542n9NuJg"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "p": 1.0830,
    "s": 100,
    "src": "NASDAQ",
    "t": 1704067200000
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

The response for this method includes the Price (p), Size (s), Source (src), and the Timestamp (t) of the trade. Standard errors can be received, and if any data is absent, the <mark style="color:red;">`null`</mark> value will be returned.

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Market%20data/getTrades>
{% endhint %}

## Get cross rates

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/crossRates`

This method is used to retrieve currency cross rates for one or more source currencies against a specified target currency. Multiple source currencies can be requested in a single call by using the `currency_from[]` query parameter. A maximum of 10 source currencies can be specified per request.

**Query**

<table><thead><tr><th width="301">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>currency_from*</code></td><td>string</td><td>Source currency code. Multiple values can be specified using bracket notation (<code>currency_from[]</code>). Maximum 10 currencies are allowed per request.</td></tr><tr><td><code>currency_to*</code></td><td>string</td><td>Target currency code. Only one target currency can be specified per request.</td></tr></tbody></table>

**CURL**&#x20;

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/crossrates?currency_from[]=USD&currency_from[]=CHF&currency_to=GBP" \
-H "accept: application/json" \
-H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAt...ANvtqQ92fTM_1EIGdm2fr4ZrL5omdKvojmrf2eR9fWSz6eZwllr-P1QvhwlG62LECoFL1kCm2gH5x_EcHV5Ff6ZwX5NDXgXL1t8MQUemeysdwIkxcM5i4YERR8s16UQ"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "rates": [
      {
        "currencyFrom": "USD",
        "currencyTo": "GBP",
        "bid": 0.86859,
        "ask": 0.86862
      },
      {
        "currencyFrom": "CHF",
        "currencyTo": "GBP",
        "bid": 0.91916,
        "ask": 0.91919
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

As a result, you will get a data object containing the *rates* array. Each object represents a currency pair and contains the source currency (*currencyFrom*), target currency (*currencyTo*), bid price, and ask price. In the example above, the request retrieves conversion rates from **USD** to **GBP** and from **CHF** to **GBP**, therefore the response contains two corresponding objects in the *rates* array.&#x20;

Currency codes are case-insensitive. If some requested currency pairs are unavailable, the response will contain only the available rates. Standard errors can be received as well.
