Candle Updates
Receive real-time OHLCV price candles for charting and technical analysis across multiple timeframes.
Note: In other exchanges this is sometime called candleSticks.
Endpoint
ws.send() wss://api.synthetix.io/v1/ws/subscriptionsSubscription Request
Subscribe to Candle Updates
{
"id": "sub-1",
"method": "subscribe",
"params": {
"type": "candles",
"symbol": "BTC-USDT",
"interval": "1m"
}
}Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Client-generated unique request identifier |
method | string | Yes | Must be "subscribe" |
params.type | string | Yes | Must be "candles" |
params.symbol | string | Yes | Trading pair symbol (e.g., "BTC-USDT") |
params.interval | string | Yes | Candle interval (e.g., "1m", "5m", "1h", "1d") |
Supported Intervals
| Interval | Description |
|---|---|
1m | 1-minute candles |
3m | 3-minute candles |
5m | 5-minute candles |
15m | 15-minute candles |
30m | 30-minute candles |
1h | 1-hour candles |
2h | 2-hour candles |
4h | 4-hour candles |
6h | 6-hour candles |
8h | 8-hour candles |
12h | 12-hour candles |
1d | 1-day candles |
1w | 1-week candles |
Candle Update Messages
New Candle
{
"method": "candle_update",
"data": {
"symbol": "BTC-USDT",
"timeframe": "1m",
"open_price": "50000.00",
"high_price": "50125.50",
"low_price": "49875.00",
"close_price": "50050.25",
"volume": "12.5",
"open_time": "2025-01-01T00:00:00Z",
"close_time": "2025-01-01T00:00:59.999Z",
"quote_volume": "625125.75",
"trade_count": 145
}
}:::warning Field Naming
WebSocket candle updates use snake_case field names (open_price, close_time, etc.) while REST API candles use camelCase. This is due to WebSocket using the internal NATS message format directly.
:::
Candle Update (In Progress)
Example of an in-progress candle (not yet closed):
{
"method": "candle_update",
"data": {
"symbol": "BTC-USDT",
"timeframe": "1m",
"open_price": "50050.25",
"high_price": "50075.00",
"low_price": "50025.00",
"close_price": "50060.50",
"volume": "3.2",
"open_time": "2025-01-01T00:01:00Z",
"close_time": "2025-01-01T00:01:59.999Z",
"quote_volume": "160193.60",
"trade_count": 42
}
}Candle Data Fields
Candle Object (REST API)
| Field | Type | Description |
|---|---|---|
openTime | integer | Candle open time (Unix milliseconds) |
closeTime | integer | Candle close time (Unix milliseconds) |
openPrice | string | Opening price of the period |
highPrice | string | Highest price during the period |
lowPrice | string | Lowest price during the period |
closePrice | string | Closing price of the period |
volume | string | Total trading volume in base asset |
quoteVolume | string | Total trading volume in quote asset |
tradeCount | integer | Number of trades in this candle |
Candle Object (WebSocket)
| Field | Type | Description |
|---|---|---|
symbol | string | Market symbol (e.g., "BTC-USDT") |
timeframe | string | Candle interval (e.g., "1m", "5m", "1h") |
open_price | string | Opening price of the period |
high_price | string | Highest price during the period |
low_price | string | Lowest price during the period |
close_price | string | Closing price of the period |
volume | string | Total trading volume in base asset |
open_time | string | Candle open time (RFC3339 format) |
close_time | string | Candle close time (RFC3339 format) |
quote_volume | string | Total trading volume in quote asset |
trade_count | integer | Number of trades in this candle |
Note: Candles are generated from actual trade executions. The open price is the first trade of the interval, and the close price is the last trade.
WebSocket Candle Update Fields
:::warning Snake Case WebSocket candle updates use snake_case field names as shown in the examples above. :::
| Field | Type | Description |
|---|---|---|
symbol | string | Trading pair symbol |
timeframe | string | Candle time interval (e.g., "1m", "5m", "1h") |
open_time | string | Candle open time (RFC3339 format) |
close_time | string | Candle close time (RFC3339 format) |
open_price | string | Opening price |
high_price | string | Highest price in the period |
low_price | string | Lowest price in the period |
close_price | string | Closing price (or current price if in progress) |
volume | string | Base asset volume |
quote_volume | string | Quote asset volume |
trade_count | integer | Number of trades in the period |
Note: WebSocket candle updates include real-time in-progress candles. The close_price represents the current price until the candle period completes.
Implementation Example
// First authenticate with EIP-712 signature
const domain = {
name: "Synthetix",
version: "1",
chainId: 1,
verifyingContract: "0x0000000000000000000000000000000000000000"
};
// Subscribe to candle updates after authentication
const subscription = {
id: "sub-1",
method: "subscribe",
params: {
type: "candles",
symbol: "BTC-USDT",
timeframe: "1m"
}
};
ws.send(JSON.stringify(subscription));
// Handle candle update messages
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.method === "candle_update") {
// WebSocket candles use snake_case field names
const { symbol, timeframe, open_price, high_price, low_price, close_price } = message.data;
console.log(`${symbol} ${timeframe} candle: O=${open_price} H=${high_price} L=${low_price} C=${close_price}`);
// Update chart with new candle data
updateCandlestickChart(message.data);
}
};
function updateCandlestickChart(candleData) {
// Destructure using actual snake_case field names
const {
open_time, // RFC3339 string
open_price,
high_price,
low_price,
close_price,
volume
} = candleData;
// Parse timestamp from RFC3339 string
const timestamp = new Date(open_time).getTime();
// Add/update candle in chart
chart.updateCandle({
time: timestamp / 1000, // TradingView expects seconds
open: parseFloat(open_price),
high: parseFloat(high_price),
low: parseFloat(low_price),
close: parseFloat(close_price),
volume: parseFloat(volume)
});
}Multiple Timeframes
Subscribe to multiple intervals for the same symbol:
// Subscribe to multiple timeframes
const subscriptions = [
{
id: "sub-1m",
method: "subscribe",
params: { type: "candles", symbol: "BTC-USDT", interval: "1m" }
},
{
id: "sub-5m",
method: "subscribe",
params: { type: "candles", symbol: "BTC-USDT", interval: "5m" }
},
{
id: "sub-1h",
method: "subscribe",
params: { type: "candles", symbol: "BTC-USDT", interval: "1h" }
}
];
subscriptions.forEach(sub => ws.send(JSON.stringify(sub)));Use Cases
Charting Applications
- Real-time Charts: Update candlestick charts with live price data
- Technical Analysis: Provide OHLCV data for technical indicators
- Multiple Timeframes: Display different chart intervals simultaneously
Trading Strategies
- Pattern Recognition: Identify candlestick patterns for trading signals
- Trend Analysis: Monitor price movements across different timeframes
- Volume Analysis: Track volume patterns for market strength
Data Collection
- Historical Data: Build historical price databases
- Market Analysis: Analyze market behavior and volatility
- Backtesting: Collect data for strategy backtesting
Implementation Notes
- Real-time Updates: In-progress candles update continuously until closed
- Closed Candles: Only add finalized candles to persistent storage
- Memory Management: Limit the number of historical candles stored in memory
- Reconnection: Re-subscribe on WebSocket reconnection to maintain data continuity
Error Handling
Subscription Errors
{
"id": "sub-1",
"status": 400,
"result": null,
"error": {
"code": 400,
"message": "Invalid interval: 2m not supported"
}
}Common Issues
| Error | Description | Solution |
|---|---|---|
| Invalid interval | Unsupported time interval | Use supported intervals (1m, 5m, 1h, etc.) |
| Invalid symbol | Symbol not available | Check supported trading pairs |
| Rate limit exceeded | Too many subscriptions | Limit concurrent subscriptions |
Related Endpoints
- Get Candle History - Historical candle data via REST
- Get Candles - Current candle data via REST
- Market Price Updates - Real-time price updates
- Get Last Trades - Individual trade executions via REST endpoint