Ticks
DataNo AuthStream real-time ticks for one or more symbols. Unchanged in the New API.
No breaking changes
The
ticks call works the same way on the Legacy API and the New API, so you don't need to change your code.Quick comparison
Request and response fields
Request
ticks(required): a symbol that matches^\w{2,30}$, or an array of symbols.subscribe(optional): accepts only1. Sends an update each time a new tick arrives.passthrough(optional): data returned to you inecho_req.req_id(optional): an ID that maps the response to your request.
Response
echo_reqandmsg_type(tick): always returned.tick: onlypip_sizeis guaranteed.ask,bid,epoch,id,quoteandsymbolare optional.subscription.id: returned when you subscribe. Pass it toforgetto stop the stream.req_id: returned when you send one.
Request structure
Legacy APIrequest example
{
"ticks": "frxEURUSD",
"subscribe": 1
}New APIrequest example
{
"ticks": "frxEURUSD",
"subscribe": 1
}Response structure
Legacy APIresponse example
{
"echo_req": {
"ticks": "frxEURUSD",
"subscribe": 1
},
"msg_type": "tick",
"subscription": {
"id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
},
"tick": {
"ask": 1.08501,
"bid": 1.08499,
"epoch": 1760000000,
"id": "c84a793b-8a87-7999-ce10-9b22f7ceead3",
"pip_size": 5,
"quote": 1.085,
"symbol": "frxEURUSD"
}
}New APIresponse example
{
"echo_req": {
"ticks": "frxEURUSD",
"subscribe": 1
},
"msg_type": "tick",
"subscription": {
"id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
},
"tick": {
"ask": 1.08501,
"bid": 1.08499,
"epoch": 1760000000,
"id": "c84a793b-8a87-7999-ce10-9b22f7ceead3",
"pip_size": 5,
"quote": 1.085,
"symbol": "frxEURUSD"
}
}Code examples
let streamId;
function subscribeTicks(symbol) {
ws.send(JSON.stringify({ ticks: symbol, subscribe: 1 }));
}
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
if (response.error) {
console.error(response.error.message);
return;
}
if (response.msg_type !== 'tick' || !response.tick) return;
const { tick, subscription } = response;
if (subscription) streamId = subscription.id; // pass to forget to stop the stream
// pip_size is the only tick field the schema guarantees
if (tick.symbol !== undefined && tick.quote !== undefined) {
console.log(tick.symbol, tick.quote.toFixed(tick.pip_size));
}
};Any other questions? Get in touch