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 TypeScript library for the Zerodha Kite Connect trading APIs. It provides a fully-typed, one-to-one replacement for the official kiteconnectjs library — your existing code works as-is, with the added benefit of TypeScript’s type safety, autocomplete, and inline documentation across all API methods and responses.

Quickstart

Install the package and make your first API call in minutes.

Authentication

Learn the Kite Connect OAuth flow and how to obtain an access token.

KiteConnect API

Place orders, fetch positions, retrieve market quotes, and more.

KiteTicker WebSocket

Stream live market ticks over WebSocket with auto-reconnect support.

What’s included

kiteconnect-ts exports two main classes and a rich set of TypeScript interfaces covering every API response shape.

KiteConnect

HTTP client for orders, portfolio, market data, mutual funds, and GTT triggers.

KiteTicker

WebSocket client for real-time LTP, quote, and full market depth tick streams.

Enums & Constants

Typed const objects for exchanges, order types, products, validities, and more.

API Reference

Complete method signatures, parameter types, and return types.

Get started in 3 steps

1

Install the package

Add kiteconnect-ts to your Node.js project using your preferred package manager.
npm install kiteconnect-ts
2

Authenticate

Initialize KiteConnect with your API key and complete the OAuth login flow to obtain an access token.
import { KiteConnect } from 'kiteconnect-ts';

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

// Redirect user to this URL to initiate login
const loginUrl = kc.getLoginURL();

// After redirect, exchange request_token for access_token
const { access_token } = await kc.generateSession(
  'request_token',
  'YOUR_API_SECRET'
);
3

Make API calls

With an access token set, call any of the typed API methods.
// Fetch equity margins
const margins = await kc.getMargins('equity');
console.log('Available cash:', margins.equity?.available.cash);

// Place an order
const { order_id } = await kc.placeOrder('regular', {
  exchange: 'NSE',
  tradingsymbol: 'INFY',
  transaction_type: 'BUY',
  quantity: 1,
  product: 'CNC',
  order_type: 'MARKET',
});
kiteconnect-ts requires Node.js v14 or later. Browser environments are not supported due to CORS restrictions imposed by Zerodha. See Browser Support for details.

Build docs developers (and LLMs) love