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 client for Kite Connect’s streaming quotes service. You instantiate it once with your credentials, call connect() to open the socket, then use subscribe() and setMode() to stream live market ticks. The class uses an exponential back-off algorithm for auto-reconnection and exposes a typed event system so you can react to ticks, order updates, connection state changes, and errors.
Public constants
The three tick-mode constants mirror the string literals accepted bysetMode(). Use the constants rather than bare strings to benefit from TypeScript autocompletion.
| Constant | Value | Description |
|---|---|---|
modeFull | 'full' | Full quote including 5-level market depth (184 bytes for tradable, 32 bytes for indices) |
modeQuote | 'quote' | Quote excluding market depth (44 bytes for tradable, 28 bytes for indices) |
modeLTP | 'ltp' | Last traded price only (8 bytes) |
Constructor
KiteTicker instance and configures auto-reconnect based on the supplied params. The WebSocket connection is not opened by the constructor — call connect() to initiate it.
Connection methods
connect()
wss://ws.kite.trade/. If the socket is already in CONNECTING or OPEN state, the call is a no-op. Once the connection is established, the connect event fires. Register your subscribe call inside that event handler to ensure tokens are sent only after the socket is ready.
disconnect()
CLOSING or CLOSED, the call is a no-op. Calling disconnect() does not suppress auto-reconnect — call autoReconnect(false) first if you want to terminate permanently.
connected()
true if the underlying WebSocket is in the OPEN state, false otherwise. Use this to guard calls that require an active connection.
Event methods
on()
The name of the event to listen for. One of:
connect, ticks, disconnect, error, close, reconnect, noreconnect, message, order_update.The typed callback function. The signature depends on the event — see the
TickerEvents type for the full map.| Event | Callback signature | Fired when |
|---|---|---|
connect | () => void | Connection established |
ticks | (ticks: any[]) => void | Tick packets received |
disconnect | (error: Error) => void | Connection dropped |
error | (error: Error) => void | Socket error |
close | () => void | Socket closed cleanly |
reconnect | (retries: number, interval: number) => void | Reconnection attempt started |
noreconnect | () => void | Max retries exhausted |
message | (data: ArrayBuffer) => void | Raw binary message received |
order_update | (order: Order) => void | Postback for a user’s order |
Subscription methods
subscribe()
getInstruments(). The default mode after subscribing is ltp.
Array of numeric instrument tokens to subscribe to.
unsubscribe()
Array of numeric instrument tokens to unsubscribe from.
setMode()
ticker.modeLTP, ticker.modeQuote, or ticker.modeFull as the mode argument. Returns the same token array.
The tick mode.
ltp streams only the last traded price; quote adds volume and OHLC; full adds 5-level market depth and open interest.Array of instrument tokens to apply the mode to.
Reconnect methods
autoReconnect()
connect() to override the values you passed to the constructor, or at any point to adjust limits dynamically.
true to enable auto-reconnect, false to disable it.Maximum number of reconnection attempts. Capped at 300.
Maximum back-off delay in seconds. Minimum is 5.