Real-Time Streaming

WebSocket Real-Time Streaming

Stream live market data with WebSocket connections. Get real-time price updates, quotes, and candlestick data from 353+ global exchanges with JWT authentication.

Core Capabilities

Real-time data streaming with price subscriptions and quote updates

Real-Time Price Updates

Live candlestick data with customizable timeframes

  • OHLCV candlestick data streaming
  • Multiple timeframes (1, 5, 15, 30, 60, 240, D, W, M)
  • Subscribe to multiple symbols simultaneously
  • Real-time price change notifications
  • Historical data retrieval support

Real-Time Quote Streaming

Live market quotes with bid/ask spreads

  • Current price and volume data
  • Bid/ask spread information
  • Price change percentage
  • Multi-symbol quote subscriptions
  • Sub-second update frequency

JWT Authentication

Secure token-based authentication system

  • Generate JWT tokens via REST API
  • Token expiration management (30 min, 1 day, 15 days)
  • Automatic connection termination on expiry
  • Secure WebSocket URL with token parameter
  • Token refresh workflow support

Connection Management

Reliable WebSocket connection handling

  • Heartbeat ping/pong support
  • Connection status monitoring
  • Welcome message with capabilities
  • Graceful disconnection handling
  • Token expiration warnings

Global Market Coverage

Stream data from 353+ exchanges worldwide

  • US markets: NYSE, NASDAQ, AMEX
  • China: SSE, SZSE, BSE (A-shares)
  • Hong Kong: HKEX
  • Crypto: Binance, Coinbase, OKX
  • Forex and Futures markets

Interactive Testing

Built-in WebSocket test interface

  • Real-time connection testing
  • Subscribe/unsubscribe functionality
  • Message history display
  • Connection status monitoring
  • Token authentication support

Common Use Cases

Build real-time applications with WebSocket price and quote streaming

Real-Time Price Monitoring

Stream live candlestick data for technical analysis and charting applications

Subscribe to price → Receive OHLCV updates → Update charts

Live Quote Dashboard

Display real-time quotes with bid/ask spreads for multiple symbols

Subscribe to quotes → Stream bid/ask data → Update dashboard

Algorithmic Trading

Execute trades based on real-time price updates with minimal latency

Price subscription → Strategy trigger → Order execution

Market Alerts

Monitor price movements and trigger alerts when thresholds are crossed

Stream prices → Threshold detection → Send notifications

Multi-Symbol Tracking

Track multiple symbols simultaneously for portfolio monitoring

Multi-symbol subscribe → Concurrent streaming → Portfolio view

Historical Data Retrieval

Fetch historical candlestick data through WebSocket connection

History request → Data retrieval → Backfill charts

Quick Start Example

Connect and start streaming in minutes

JavaScript
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);

Get Started

Three steps to real-time market data

1

Generate JWT Token

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 →
2

Connect to WebSocket

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
3

Subscribe & Stream

Send subscription messages for price updates or quotes. Use heartbeat ping/pong to keep the connection alive.

Try Live Demo →

Ready to Stream Real-Time Data?

Start building real-time applications with WebSocket price and quote streaming. Generate your JWT token and connect today.