Stream live market data with WebSocket connections. Get real-time price updates, quotes, and candlestick data from 353+ global exchanges with JWT authentication.
Real-time data streaming with price subscriptions and quote updates
Live candlestick data with customizable timeframes
Live market quotes with bid/ask spreads
Secure token-based authentication system
Reliable WebSocket connection handling
Stream data from 353+ exchanges worldwide
Built-in WebSocket test interface
Build real-time applications with WebSocket price and quote streaming
Stream live candlestick data for technical analysis and charting applications
Subscribe to price → Receive OHLCV updates → Update charts Display real-time quotes with bid/ask spreads for multiple symbols
Subscribe to quotes → Stream bid/ask data → Update dashboard Execute trades based on real-time price updates with minimal latency
Price subscription → Strategy trigger → Order execution Monitor price movements and trigger alerts when thresholds are crossed
Stream prices → Threshold detection → Send notifications Track multiple symbols simultaneously for portfolio monitoring
Multi-symbol subscribe → Concurrent streaming → Portfolio view Fetch historical candlestick data through WebSocket connection
History request → Data retrieval → Backfill charts Connect and start streaming in minutes
import WebSocket from 'ws';
// Step 1: Generate JWT token via REST API
const response = await fetch('https://api.tradingviewapi.com/api/token/generate', {
method: 'POST',
headers: {
'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
'X-RapidAPI-Host': 'tradingview-data1.p.rapidapi.com'
}
});
const { token, wsUrl, expiresAt } = await response.json();
// Step 2: Connect to WebSocket with token
const ws = new WebSocket(`${wsUrl}?token=${token}`);
ws.on('open', () => {
console.log('Connected to TradingView WebSocket');
// Subscribe to price updates
ws.send(JSON.stringify({
action: 'subscribe',
id: 'price_btc',
symbol: 'BINANCE:BTCUSDT',
timeframe: '5'
}));
// Subscribe to real-time quotes
ws.send(JSON.stringify({
action: 'subscribe_quote',
id: 'quote_btc',
symbol: 'BINANCE:BTCUSDT'
}));
});
ws.on('message', (data) => {
const message = JSON.parse(data);
if (message.type === 'price') {
console.log('Price update:', message.data);
} else if (message.type === 'quote') {
console.log('Quote update:', message.data);
}
});
// Heartbeat to keep connection alive
setInterval(() => {
ws.send(JSON.stringify({ action: 'ping' }));
}, 30000); Three steps to real-time market data
Call the token generation endpoint to get your JWT token and WebSocket URL. Tokens expire after 30 minutes, 1 day, or 15 days depending on type.
View Token API →Use the WebSocket URL from the token response and append your JWT token as a query parameter.
wss://ws.tradingviewapi.com/ws?token=YOUR_TOKEN Send subscription messages for price updates or quotes. Use heartbeat ping/pong to keep the connection alive.
Try Live Demo →Start building real-time applications with WebSocket price and quote streaming. Generate your JWT token and connect today.