An unofficial Node.js library for interacting with TradingView's WebSocket API. Current version 0.0.3 provides real-time data, authorization via session ID, and candlestick fetching for any symbol and timeframe. Supports up to ~13,000 candles per request for hourly timeframes. Features TypeScript definitions and ESM-only exports. Key differentiators: lightweight, promise-based, and direct WebSocket access without browser emulation. Release cadence is irregular; use with caution for production.
npm install tradingview-wsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes a WebSocket connection, fetches 10,000 hourly candlesticks for two FX pairs, then closes the connection.
Use import syntax or dynamic import() in CommonJS modules. Set 'type': 'module' in package.json if using ESM.
Pass a valid sessionId in connect options to get full data access.
Do not request more than 13,000 candles per call; split requests if needed.
Replace require with import: `import { connect, getCandles } from 'tradingview-ws'`Ensure correct import: `import WebSocket from 'ws'` if using CommonJS in a ESM project, but prefer the library's own interface.
Verify symbol names from TradingView's symbol info modal and provide a valid sessionId.