Ticks
Subscribe to real-time tick stream for market data. Required response fields changed and subscribe parameter extended.
4 breaking changes - code updates required
Critical Changes:
Required fields in tick response changed. The tick object is now always present and pip_size is no longer guaranteed.
Quick comparison
| Aspect | Legacy | New | Action required |
|---|---|---|---|
Endpoint ✅ Same | ticks | ticks | None |
Auth Required ✅ Same | No | No | None |
Subscribe Values ⚠️ Changed | 1 only | 0 or 1 | Optional: use 0 for single tick |
tick Object ⚠️ Changed | Optional | Required | Update response handling |
pip_size Field ⚠️ Changed | Required | Optional | Add existence check |
Input Validation ⚠️ Changed | Pattern enforced | No pattern | None (relaxed) |
Breaking changes
1. Required fields in tick response changed
What 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
Migration: 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
What Changed: 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
Migration: 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
What Changed: The subscribe parameter now accepts both 0 and 1.
- Legacy: Only
1was valid - New:
0(single tick, no subscription) or1(continuous stream)
Migration: This is a new capability. Use subscribe: 0 when you only need a single tick snapshot without ongoing updates.
4. Input validation pattern removed
What Changed: The pattern validation on the ticks parameter has been removed.
- Legacy: Pattern
^\w{2,30}$was enforced - New: No pattern validation on symbol names
Migration: 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
Legacy Request Example
1// Subscription mode (only option in legacy)
2{
3 "ticks": "frxEURUSD",
4 "subscribe": 1
5}
6
7// Array of symbols
8{
9 "ticks": ["frxEURUSD", "frxGBPUSD"],
10 "subscribe": 1
11}New Request Example
1// Subscription mode (continuous stream)
2{
3 "ticks": "frxEURUSD",
4 "subscribe": 1
5}
6
7// Single tick snapshot (NEW in v4)
8{
9 "ticks": "frxEURUSD",
10 "subscribe": 0
11}
12
13// Array of symbols
14{
15 "ticks": ["frxEURUSD", "frxGBPUSD"],
16 "subscribe": 1
17}Response structure
Legacy Response Example
1{
2 "echo_req": { // Required in legacy
3 "ticks": "frxEURUSD",
4 "subscribe": 1
5 },
6 "tick": { // Optional in legacy
7 "ask": 1.08501,
8 "bid": 1.08499,
9 "epoch": 1234567890, // Optional
10 "id": "tick-id-123",
11 "pip_size": 5, // REQUIRED in legacy
12 "quote": 1.08500, // Optional
13 "symbol": "frxEURUSD" // Optional
14 },
15 "msg_type": "tick",
16 "subscription": { "id": "sub-123" }
17}New Response Example
1{
2 "echo_req": { // Now optional
3 "ticks": "frxEURUSD",
4 "subscribe": 1
5 },
6 "tick": { // REQUIRED in new API
7 "ask": 1.08501,
8 "bid": 1.08499,
9 "epoch": 1234567890, // REQUIRED
10 "id": "tick-id-123",
11 "pip_size": 5, // Now optional
12 "quote": 1.08500, // REQUIRED
13 "symbol": "frxEURUSD" // REQUIRED
14 },
15 "msg_type": "tick",
16 "subscription": { "id": "sub-123" }
17}Code examples
Legacy Implementation
1async function subscribeTicks(symbol) {
2 const request = {
3 ticks: symbol,
4 subscribe: 1 // Only 1 is valid
5 };
6
7 ws.send(JSON.stringify(request));
8
9 ws.onmessage = (event) => {
10 const response = JSON.parse(event.data);
11 if (response.msg_type === 'tick') {
12 // tick object may not exist
13 if (response.tick) {
14 // pip_size is guaranteed
15 const pipSize = response.tick.pip_size;
16
17 // These fields are optional
18 const quote = response.tick.quote;
19 const epoch = response.tick.epoch;
20 const symbol = response.tick.symbol;
21
22 console.log('Pip size:', pipSize);
23 if (quote) console.log('Quote:', quote);
24 }
25
26 // echo_req is always available
27 console.log('Request:', response.echo_req);
28 }
29 };
30}New Implementation
1async function subscribeTicks(symbol, subscribe = 1) {
2 const request = {
3 ticks: symbol,
4 subscribe // Can be 0 or 1
5 };
6
7 ws.send(JSON.stringify(request));
8
9 ws.onmessage = (event) => {
10 const response = JSON.parse(event.data);
11 if (response.msg_type === 'tick') {
12 // tick object is guaranteed to exist
13 const { tick } = response;
14
15 // These fields are guaranteed
16 const { quote, epoch, symbol } = tick;
17 console.log('Quote:', quote);
18 console.log('Epoch:', epoch);
19 console.log('Symbol:', symbol);
20
21 // pip_size is now optional
22 if (tick.pip_size !== undefined) {
23 console.log('Pip size:', tick.pip_size);
24 }
25
26 // echo_req may not be present
27 if (response.echo_req) {
28 console.log('Request:', response.echo_req);
29 }
30 }
31 };
32}
33
34// New: Get single tick without subscription
35async function getSingleTick(symbol) {
36 const request = {
37 ticks: symbol,
38 subscribe: 0 // New in v4
39 };
40 ws.send(JSON.stringify(request));
41}