Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/anurag-roy/kiteconnect-ts/llms.txt

Use this file to discover all available pages before exploring further.

KiteTicker is the WebSocket streaming client in kiteconnect-ts. It connects to Kite’s quote streaming service and delivers live market tick data for any set of instrument tokens you subscribe to. You can control how much data you receive per tick by choosing between three modes — from a minimal last-traded-price packet to a full market-depth snapshot — and the client handles reconnection automatically so your feed stays alive through transient network failures.

Constructor

Create a ticker instance by passing a KiteTickerParams object to the constructor. Auto-reconnect is enabled by default.
api_key
string
required
Your Kite Connect API key.
access_token
string
required
The access token obtained after a successful login flow.
reconnect
boolean
default:"true"
Enable or disable automatic reconnection on disconnect.
max_retry
number
default:"50"
Maximum number of reconnection attempts before giving up. Accepted range: 1–300.
max_delay
number
default:"60"
Maximum delay in seconds between reconnection attempts. Minimum acceptable value is 5.
root
string
default:"\"wss://ws.kite.trade/\""
Override the Kite WebSocket root URL. Use this only for testing or custom environments.

Quick start

The example below connects to Kite’s streaming service, subscribes to an instrument, and logs incoming ticks.
import { KiteTicker } from "kiteconnect-ts";

const ticker = new KiteTicker({
  api_key: "api_key",
  access_token: "access_token",
});

ticker.connect();
ticker.on("connect", subscribe);
ticker.on("ticks", onTicks);

function subscribe() {
  const tokens = [738561];
  ticker.subscribe(tokens);
  ticker.setMode(ticker.modeFull, tokens);
}

function onTicks(ticks) {
  console.log("Ticks", ticks);
}
1

Instantiate KiteTicker

Pass your api_key and access_token. Auto-reconnect is on by default.
2

Call connect()

Opens the WebSocket connection to wss://ws.kite.trade/. The connect event fires when the handshake completes.
3

Subscribe inside the connect handler

Call subscribe() and setMode() inside your connect callback so they run after the socket is open and again after every reconnection.
4

Handle ticks

Register a ticks handler to receive arrays of parsed tick objects on every market update.

Tick modes

Each subscribed token streams data at the mode you assign. You can assign different modes to different tokens.
ModeConstantPacket sizeContents
ltpticker.modeLTP8 bytesLast traded price only
quoteticker.modeQuote44 bytes (tradable), 28 bytes (index)LTP, OHLC, volume, buy/sell quantities
fullticker.modeFull184 bytes (tradable), 32 bytes (index)Quote data + 5-level market depth + open interest

Public mode constants

The ticker exposes three read-only constants you should use instead of raw strings:
ticker.modeFull   // 'full'
ticker.modeQuote  // 'quote'
ticker.modeLTP    // 'ltp'

Auto-reconnect

Auto-reconnect is enabled by default and uses an exponential backoff algorithm. The reconnect interval starts at 2 seconds and doubles on each failed attempt — 2^attempt seconds — until it reaches max_delay, after which it stays constant. Reconnection stops after max_retry attempts.
// Customise reconnection: 10 attempts, 5-second cap
ticker.autoReconnect(true, 10, 5);
The reconnect event fires on each attempt and the noreconnect event fires when retries are exhausted.

Subscribing

Subscribe to instruments, set tick modes, and manage your active subscriptions.

Events

Handle connection lifecycle, tick data, order updates, and reconnection events.

Build docs developers (and LLMs) love