Server-Sent Events

SSE Real-Time Streaming

Stream live market data with Server-Sent Events. Get real-time price updates and quotes from 353+ global exchanges — with automatic browser reconnect and zero extra dependencies.

One-way push — simpler than WebSocket
Auto-reconnect built into the browser
Works over standard HTTP/2

SSE vs WebSocket

Choose the right streaming protocol for your use case

SSE

Server-Sent Events

Best for one-way server-to-client streaming

  • Native browser auto-reconnect
  • Works over standard HTTP/2
  • No extra libraries needed
  • Simpler implementation
  • Firewall/proxy friendly
  • One-way (server → client only)
WebSocket

WebSocket

Best for two-way real-time communication

  • Full-duplex bidirectional
  • Lower latency per message
  • Subscribe/unsubscribe at runtime
  • Send heartbeat pings
  • Manual reconnect logic required
  • Requires WebSocket-aware proxies

Core Capabilities

Real-time data streaming with automatic reconnect and global market coverage

Real-Time Quote Streaming

Push live market quotes directly to your browser or server

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

Real-Time Price Updates

Live candlestick OHLCV data pushed via SSE stream

  • 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
  • Configurable timeframe per connection

Automatic Reconnect

Built-in browser reconnect with no extra code required

  • Native EventSource auto-reconnect
  • Browser handles connection drops automatically
  • No custom reconnect logic needed
  • Seamless resume after network interruptions
  • Last-Event-ID support for gap recovery

JWT Authentication

Secure token-based authentication for SSE connections

  • Generate JWT tokens via REST API
  • Token expiration management
  • Automatic connection termination on expiry
  • Secure SSE URL with token parameter
  • Same token endpoint as WebSocket

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

Simple Integration

Lightweight one-way push with browser-native EventSource API

  • Native browser EventSource support
  • No additional libraries required
  • Works with any HTTP client supporting SSE
  • Compatible with Node.js, Python, and more
  • Easy to use with React, Vue, and other frameworks

Common Use Cases

Build real-time applications with SSE price and quote streaming

Live Price Dashboard

Push real-time quotes to a dashboard with automatic browser reconnect support

Connect SSE → Receive quote events → Update UI

Server-Side Data Pipeline

Stream market data to your backend for processing, storage, or further distribution

SSE stream → Process events → Store / forward

Price Alert System

Monitor streaming prices server-side and trigger alerts when thresholds are crossed

Stream prices → Threshold check → Send alerts

Multi-Symbol Portfolio Tracker

Track a portfolio of symbols with a single SSE connection using comma-separated symbols

symbols=AAPL,TSLA,BTC → Stream all → Portfolio view

Candlestick Chart Updates

Receive live OHLCV candlestick data to keep charts updated in real time

type=price&timeframe=5 → OHLCV events → Chart update

Mobile & Web Apps

Use SSE instead of WebSocket when you only need one-way server-to-client data flow

EventSource connect → Receive events → Render UI

Connection Parameters

Customize your SSE stream with these query parameters

Parameter Required Description Example
token Required JWT authentication token from /api/token/generate eyJhbGci...
symbols Required Comma-separated list of symbols to subscribe to NASDAQ:AAPL,NYSE:TSLA
type Optional Subscription type: quote (default) or price quote
timeframe Optional Candle timeframe when type=price (default: 5) 1, 5, 15, 60, D
SSE Endpoint GET https://ws.tradingviewapi.com/sse/stream?token=TOKEN&symbols=SYMBOLS

Quick Start Example

Connect and start streaming in minutes

JavaScript
// Step 1: Generate JWT token via REST API
const tokenRes = 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',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({})
});

const { token, sseUrl } = await tokenRes.json();

// Step 2: Connect to SSE stream
const symbols = 'NASDAQ:AAPL,NYSE:TSLA,BINANCE:BTCUSDT';
const url = `${sseUrl}?token=${token}&symbols=${symbols}&type=quote`;

const eventSource = new EventSource(url);

eventSource.onopen = () => {
    console.log('SSE connection established');
};

eventSource.onmessage = (event) => {
    const data = JSON.parse(event.data);

    if (data.type === 'connected') {
        console.log('Connected, streaming:', data.symbols);
    } else if (data.type === 'quote_update') {
        console.log(`${data.symbol}: ${data.data.lp}`);
    }
};

eventSource.onerror = (err) => {
    console.error('SSE error:', err);
    // Browser will auto-reconnect — no extra logic needed
};

// To stream price candles instead of quotes:
// const url = `${sseUrl}?token=${token}&symbols=BINANCE:BTCUSDT&type=price&timeframe=5`;

Get Started

Three steps to real-time SSE market data

1

Generate JWT Token

Call /api/token/generate to get your JWT token and SSE URL. The same endpoint is used for both WebSocket and SSE connections.

View Token API →
2

Connect to SSE Stream

Use the sseUrl from the token response and append your JWT token plus the symbols you want to track.

new EventSource(sseUrl + '?token=TOKEN&symbols=NASDAQ:AAPL')
3

Receive Events

Handle onmessage events to process real-time quote or price updates. The browser auto-reconnects if the connection drops.

Full Documentation →

Event Payload Examples

SSE events are JSON-encoded strings sent as standard data: fields

connected Sent on successful connection
{
  "type": "connected",
  "clientId": "sse_abc123",
  "symbols": ["NASDAQ:AAPL", "NYSE:TSLA"],
  "timestamp": 1234567890
}
quote_update Real-time quote data (type=quote)
{
  "type": "quote_update",
  "symbol": "NASDAQ:AAPL",
  "data": { "lp": 195.42 },
  "timestamp": 1234567891
}
price_update OHLCV candlestick data (type=price)
{
  "type": "price_update",
  "symbol": "BINANCE:BTCUSDT",
  "data": {
    "open": 68100, "high": 68250,
    "low": 67980, "close": 68200,
    "volume": 1240.5
  },
  "timestamp": 1234567892
}

Ready to Stream Real-Time Data?

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