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.

The KiteTickerParams interface defines the configuration object you pass to the KiteTicker constructor. Both api_key and access_token are required. Auto-reconnect is enabled by default with sensible limits that you can tune through max_retry and max_delay.
import { KiteTicker } from 'kiteconnect-ts';

const ticker = new KiteTicker({
  api_key: 'YOUR_API_KEY',
  access_token: 'YOUR_ACCESS_TOKEN',
  reconnect: true,    // optional, default true
  max_retry: 50,      // optional
  max_delay: 60,      // optional, seconds
  root: 'wss://ws.kite.trade/', // optional
});

Parameters

api_key
string
required
The API key issued to you by Zerodha. This is the same key you use with KiteConnect and it is sent as part of the WebSocket handshake URL.
access_token
string
required
The access token obtained after a successful login flow. Unlike KiteConnectParams, this field is required on the ticker — there is no way to set it later via a method call.
reconnect
boolean
default:"true"
Enable or disable automatic reconnection when the WebSocket connection drops. When true, the ticker uses an exponential backoff algorithm to schedule reconnection attempts.Default: true
max_retry
number
default:"50"
The maximum number of reconnection attempts before the ticker gives up and fires the noreconnect event. The absolute ceiling is 300; values above 300 are clamped to 300.Default: 50 | Maximum: 300
max_delay
number
default:"60"
The maximum back-off delay in seconds. After the exponential interval reaches this value, subsequent attempts wait a constant max_delay seconds. Values below 5 are clamped to 5.Default: 60 | Minimum: 5
root
string
default:"wss://ws.kite.trade/"
The WebSocket server URL. Override this only when connecting to a custom or staging endpoint.Default: "wss://ws.kite.trade/"

Full example

import { KiteTicker } from 'kiteconnect-ts';

const ticker = new KiteTicker({
  api_key: process.env.KITE_API_KEY!,
  access_token: process.env.KITE_ACCESS_TOKEN!,
  reconnect: true,
  max_retry: 10,
  max_delay: 30,
});

ticker.connect();

ticker.on('connect', () => {
  ticker.subscribe([738561]);
  ticker.setMode(ticker.modeFull, [738561]);
});

ticker.on('noreconnect', () => {
  console.error('Max reconnection attempts reached, exiting.');
  process.exit(1);
});
The reconnect event fires on every individual attempt, passing the current retry count and the next interval (in seconds) as arguments. Use this to log reconnection progress without blocking the attempt.

Build docs developers (and LLMs) love