Documentation

Ticks history

DataNo Auth

Get historical tick data for a symbol. Only the default value of the count parameter changed.

Quick comparison

AspectLegacy APINew APIAction
Endpointticks_historyticks_historyNone
Auth RequiredNoNoNone
Default count50001000Set count explicitly

Breaking changes

1. Default value of count changed

The count parameter is unchanged, but its default value when you do not send it is lower in the New API.

  • Legacy: count defaults to 5000 ticks per request.
  • New: count defaults to 1000 ticks per request.

Required change: If you need more than 1000 ticks and do not send count, send it explicitly.

Request structure

Legacy APIrequest example
{
  "ticks_history": "frxEURUSD",
  "end": "latest",
  "start": 1234567890,
  "style": "ticks",
  "count": 100,
  "adjust_start_time": 1,
  "subscribe": 1
}
New APIrequest example
{
  "ticks_history": "frxEURUSD",
  "end": "latest",
  "start": 1234567890,
  "style": "ticks",
  "count": 100,
  "adjust_start_time": 1,
  "subscribe": 1
}

Response structure

Legacy APIresponse example
{
  "echo_req": {
    "ticks_history": "frxEURUSD",
    "end": "latest",
    "start": 1234567890,
    "style": "ticks",
    "count": 100,
    "adjust_start_time": 1,
    "subscribe": 1
  },
  "history": {
    "prices": [
      1.085,
      1.0851
    ],
    "times": [
      1234567890,
      1234567891
    ]
  },
  "msg_type": "history",
  "pip_size": 5,
  "subscription": {
    "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
  }
}
New APIresponse example
{
  "echo_req": {
    "ticks_history": "frxEURUSD",
    "end": "latest",
    "start": 1234567890,
    "style": "ticks",
    "count": 100,
    "adjust_start_time": 1,
    "subscribe": 1
  },
  "history": {
    "prices": [
      1.085,
      1.0851
    ],
    "times": [
      1234567890,
      1234567891
    ]
  },
  "msg_type": "history",
  "pip_size": 5,
  "subscription": {
    "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
  }
}

Code examples

async function getTicksHistory(symbol) {
  const request = {
    ticks_history: symbol,
    end: "latest",
    start: Date.now() / 1000 - 86400,
    style: "ticks",
    count: 100,  // Defaults to 5000 when omitted
    adjust_start_time: 1,
    subscribe: 1
  };

  ws.send(JSON.stringify(request));

  ws.onmessage = (event) => {
    const response = JSON.parse(event.data);

    // echo_req is guaranteed
    console.log('Request:', response.echo_req);

    if (response.msg_type === 'history') {
      // history.prices and history.times are optional
      if (response.history) {
        if (response.history.prices) {
          console.log('Prices:', response.history.prices);
        }
        if (response.history.times) {
          console.log('Times:', response.history.times);
        }
      }
    }

    if (response.msg_type === 'candles') {
      // Each candle property is optional
      response.candles?.forEach(candle => {
        const close = candle.close ?? null;
        const open = candle.open ?? null;
        const high = candle.high ?? null;
        const low = candle.low ?? null;
        console.log({ open, high, low, close });
      });
    }
  };
}
Click to open live chat support. Get instant help from our support team.