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.

kiteconnect-ts is an unofficial, community-maintained library that mirrors the official Zerodha kiteconnectjs API one-to-one. Every class, method, and constant is identical, so you can switch packages and your existing code will continue to work as-is. The only thing you gain immediately is TypeScript types.
kiteconnect-ts is not the official Zerodha library. It is an independent TypeScript port maintained by the community. The official package is kiteconnectjs.

Migration steps

1

Replace the package

Uninstall kiteconnectjs and install kiteconnect-ts.
npm uninstall kiteconnect
npm install kiteconnect-ts
2

Update your import

Change the package name in your import statement. Nothing else in the import needs to change — named exports like KiteConnect and KiteTicker are identical.
- const { KiteConnect } = require('kiteconnect');
+ import { KiteConnect } from 'kiteconnect-ts';
If you are already using ES module imports:
- import { KiteConnect } from 'kiteconnect';
+ import { KiteConnect } from 'kiteconnect-ts';
3

Verify your existing code still works

No further changes are required for basic usage. Initialise the class and call methods exactly as before.
import { KiteConnect } from 'kiteconnect-ts';

const kc = new KiteConnect({
  api_key: 'YOUR_API_KEY',
});

// Everything below is unchanged from kiteconnectjs
const { access_token } = await kc.generateSession(
  'request_token',
  'YOUR_API_SECRET'
);

kc.setAccessToken(access_token);

const orders = await kc.getOrders();

Class member constants still work

If your kiteconnectjs code used instance constants like kc.EXCHANGE_NSE or kc.PRODUCT_MIS, they continue to work without any changes. They are preserved on the KiteConnect instance as readonly properties.
import { KiteConnect } from 'kiteconnect-ts';

const kc = new KiteConnect({ api_key: 'YOUR_API_KEY' });

// These all work exactly as in kiteconnectjs
const order = await kc.placeOrder(kc.VARIETY_REGULAR, {
  exchange: kc.EXCHANGE_NSE,
  tradingsymbol: 'INFY',
  transaction_type: kc.TRANSACTION_TYPE_BUY,
  quantity: 1,
  product: kc.PRODUCT_CNC,
  order_type: kc.ORDER_TYPE_MARKET,
});

Gradually adopting TypeScript types

Once you have migrated, you can start adding types incrementally. kiteconnect-ts exports interfaces and const objects for every parameter and response shape.
import {
  KiteConnect,
  PlaceOrderParams,
  Order,
  Exchange,
  ProductType,
  OrderType,
} from 'kiteconnect-ts';

const kc = new KiteConnect({ api_key: 'YOUR_API_KEY' });

// Use PlaceOrderParams to type your order objects
const params: PlaceOrderParams = {
  exchange: Exchange.NSE,
  tradingsymbol: 'INFY',
  transaction_type: 'BUY',
  quantity: 1,
  product: ProductType.CNC,
  order_type: OrderType.MARKET,
};

const { order_id } = await kc.placeOrder('regular', params);

// Response types are inferred automatically
const orders: Order[] = await kc.getOrders();

Notable changes in kiteconnect-ts

The following changes were introduced across kiteconnect-ts versions. They are all additive and do not break kiteconnectjs compatibility.
VersionChange
1.1.1Date object returned in socket order payload instead of a string
1.1.0getQuote, getLTP, getOHLC now accept a single instrument string in addition to an array
1.1.0crypto-js dependency removed; Node.js built-in crypto module is used instead
1.0.0KiteTicker event callbacks are fully typed
0.5.0Exported const objects (Exchange, ProductType, etc.) added
0.4.3modeFull, modeQuote, modeLTP on KiteTicker made non-static for kiteconnectjs compatibility
0.3.0Full rewrite to match kiteconnectjs APIs for easy migration

Build docs developers (and LLMs) love