Ticks
DataNo AuthSubscribe to real-time tick stream for market data. Required response fields changed and subscribe parameter extended.
4 Breaking Changes
tick object is now always present and pip_size is no longer guaranteed.Quick comparison
Breaking changes
1. Required fields in tick response changed
The required fields inside the tick object have changed:
- Legacy: Only
pip_sizewas required. - New:
epoch,quote, andsymbolare now required. pip_sizeis now optional and may not always be present.
Required change: Add existence checks before accessing pip_size. You can now rely on epoch, quote, and symbol always being present.
2. Tick object now required in response
The tick object is now a required field in the response.
- Legacy: Only
echo_reqandmsg_typewere required at top level. - New:
tickandmsg_typeare required;echo_reqis now optional.
Required change: You can now safely access response.tick without checking for existence. Update any code that relies on echo_req always being present.
3. Subscribe parameter now accepts 0
The subscribe parameter now accepts both 0 and 1.
- Legacy: Only
1was valid. - New:
0(single tick, no subscription) or1(continuous stream).
Required change: This is a new capability. Use subscribe: 0 when you only need a single tick snapshot without ongoing updates.
4. Input validation pattern removed
The pattern validation on the ticks parameter has been removed.
- Legacy: Pattern
^\w{2,30}$was enforced. - New: No pattern validation on symbol names.
Required change: This change relaxes input validation. Existing valid symbol names will continue to work. If you relied on the API to validate symbol format, consider adding client-side validation.
Request structure
{
"ticks": "frxEURUSD",
"subscribe": 1
}{
"ticks": "frxEURUSD",
"subscribe": 1
}Response structure
{
"echo_req": { // Required in legacy
"ticks": "frxEURUSD",
"subscribe": 1
},
"tick": { // Optional in legacy
"ask": 1.08501,
"bid": 1.08499,
"epoch": 1234567890, // Optional
"id": "tick-id-123",
"pip_size": 5, // REQUIRED in legacy
"quote": 1.08500, // Optional
"symbol": "frxEURUSD" // Optional
},
"msg_type": "tick",
"subscription": { "id": "sub-123" }
}{
"echo_req": { // Now optional
"ticks": "frxEURUSD",
"subscribe": 1
},
"tick": { // REQUIRED in new API
"ask": 1.08501,
"bid": 1.08499,
"epoch": 1234567890, // REQUIRED
"id": "tick-id-123",
"pip_size": 5, // Now optional
"quote": 1.08500, // REQUIRED
"symbol": "frxEURUSD" // REQUIRED
},
"msg_type": "tick",
"subscription": { "id": "sub-123" }
}Code examples
async function subscribeTicks(symbol) {
const request = {
ticks: symbol,
subscribe: 1 // Only 1 is valid
};
ws.send(JSON.stringify(request));
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
if (response.msg_type === 'tick') {
// tick object may not exist
if (response.tick) {
// pip_size is guaranteed
const pipSize = response.tick.pip_size;
// These fields are optional
const quote = response.tick.quote;
const epoch = response.tick.epoch;
const symbol = response.tick.symbol;
console.log('Pip size:', pipSize);
if (quote) console.log('Quote:', quote);
}
// echo_req is always available
console.log('Request:', response.echo_req);
}
};
}Any other questions? Get in touch