[2.0.0] β 2026-04-10
First release of the V2 architecture. Complete rewrite with a new
public API, full TypeScript types, and a clean lifecycle model.
See MIGRATION.md for the full 1.x β 2.0 guide.
Added
Public API
tv(options)factory function returning aClient.Clientwith lifecycle (connect,disconnect, events,Symbol.asyncDispose).TvSymbolwithprice(),snapshot(),info(),candles(),stream().Streamwith typed events (price,change,update,bar,error),
Symbol.dispose, andSymbol.asyncIterator.Portfolioβ ad-hoc multi-symbol collection (client.symbols([...])).Groupβ named, mutable collection with liveadd/remove/
has/clearpropagating to active streams.GroupRegistryβMap-like container atclient.groups.MultiStreamβ shared multi-symbol stream base used byPortfolio,
Group, andclient.stream().client.stream()β aggregate multi-symbol stream with automatic
dedup across overlapping groups.- Full typed quote field system:
QuoteField,QuoteFieldTypeMap,QuoteSnapshot<F>,
FullQuoteSnapshot,TradeTick,BarTick. - Candle types:
Candle,Timeframe,RawTimeframe,
TimeframeAlias,normalizeTimeframe. SymbolInfowith camelCase fields and an index signature for
forward-compatibility.- Error hierarchy:
TvError,TvConnectionError,TvProtocolError,
TvSessionError,TvSymbolError,TvTimeoutError.
Internal API
The tradingview-api-adapter/internal subpath exports low-level
primitives for advanced users. These are semver-exempt β breaking
changes may happen in minor versions.
Transportβ WebSocket lifecycle with reconnect and buffering.Protocolβ pureencodeFrame/decodeFrames/encodeCommand/encodeHeartbeat.SessionManagerβ transport owner, heartbeat, routing, replay.QuoteSession/ChartSessionβ TradingView session logic.SymbolBatcherβ the rate limiter used to coalesce add/remove ops.- Utilities:
calculateBackoff,randomId,createLogger,
kebabToCamel,transformKeys,symbolInfoFromRaw.
Resilience
- Automatic reconnect with exponential backoff + jitter.
- Session replay: quote and chart sessions are re-registered after
reconnect so consumer code never sees the outage. - Heartbeat auto-response handled inside
SessionManager. - Rate limiter with 50 ms micro-batching, 50-symbol chunks, and
cancel-within-window dedup (add('X') + remove('X')in the same
window emits nothing).
Authentication
auth.sessionid/auth.sessionidSignβ sent asCookieheader
on the WebSocket handshake (Node only).auth.authTokenβ sent viaset_auth_tokenmessage after the
server hello, defaults to"unauthorized_user_token".localeoption β sent viaset_localeafter auth.
Browser / dual runtime
- Dynamic
import('ws')so browser bundlers drop the Nodews
package from client builds. - Automatic runtime detection: native
WebSocketin browsers,
wsin Node, fallback to native in Bun / Deno / Cloudflare Workers. happy-domtest environment for browser smoke tests.
Proxy support
agentoption accepted bytv(), propagated through to thews
package. Works withhttps-proxy-agent,socks-proxy-agent, or
anyhttp.Agent-compatible proxy client.
Documentation
- Rewritten README with quick start, feature list, and examples table.
docs/getting-started.mdβ installation, concepts, troubleshooting.docs/api/β full reference forClient,TvSymbol,Stream,
Portfolio/Group, and types.docs/guides/β streaming, candles, groups, reconnect, browser,
proxy, auth.MIGRATION.mdβ complete 1.x β 2.0 migration guide.CONTRIBUTING.mdβ development workflow,.jsextension rationale.
Examples
12 runnable demos in examples/:
01-single-price.ts02-streaming.ts03-multi-symbol.ts04-groups.ts05-candles-history.ts06-candles-streaming.ts07-symbol-info.ts08-async-iterator.ts09-reconnect-resilience.ts10-browser.html11-proxy-node.ts12-auth-session.ts
Testing and tooling
- 227+ unit tests across 21 files in
tests/unit/. - Mock WebSocket server in
tests/fixtures/ws-server.tsfor
integration-like tests without touching the network. - Live e2e scaffolding gated by
LIVE_E2E=1environment variable. - Vitest +
@vitest/coverage-v8with 85% statement threshold. - ESLint 9 (flat config) + Prettier.
tsupdual ESM + CJS build with.d.tsand.d.ctstypes.publintpre-publish validation.- GitHub Actions CI (Node 20 & 22), nightly e2e, tag-triggered
release workflow with npm provenance.
Changed
- Minimum Node version: 20 (was 14).
- Package is now ESM-first (
"type": "module") with a CJS fallback. keywordsinpackage.jsontrimmed to 10 honest entries from 12
(removedtradingview-webhooks,tradingview-indicator,
bitcoin,dogecoin, and de-duplicated stock-related keywords).- Security: upgraded
wsto^8.18.0(fixes
GHSA-3h5v-q93c-6h6q).
Removed
- Legacy 1.x source code:
src/Client.ts,src/Quote.ts,
src/QuoteChannel.ts,src/TickerDetails.ts,src/WsProtocol.ts,
src/adapters/*,demos/*. Replaced by the new architecture.
Fixed
- #4 β
Unable to close WS connection.client.disconnect()now releases
every resource and allows the Node process to exit. - #5 β
Uncleartrade/minute-bar/daily-bartypes. The
QuoteFieldTypeMapnow declares fullTradeTickandBarTick
interfaces with TypeScript checking. - #6 β
Mobile browser quotes. Browser detection now uses the native
WebSocketwhen available and thewspackage is dropped from
browser bundles via dynamic import. - #7 β
Vue 3 WebSocket error. Same dynamic import fix. - #9 β
Proxy server.agentoption now propagates through the full
ClientβSessionManagerβTransportstack.