zerokite
v0.3.15
Published
Unofficial CLI for Zerodha Kite API
Readme
zerokite CLI (CLI for Zerodha's Kite APIs)
zerokite is an unofficial command-line client for interacting with Zerodha's Kite API.
Goal
Provide a fast and scriptable way to use Kite APIs directly from the terminal without implying an official Zerodha CLI.
Tech Stack
- Node.js (18+ recommended)
Installation
Install from npm:
npm install -g zerokiteVerify install:
zerokite helpAfter install, you can enable shell completions:
zerokite completion bash
zerokite completion zshLocal Development Setup
- Clone this repo and install dependencies:
npm install
npm link- Verify linked local CLI:
zerokite helpKite App Configuration
Create a Kite Connect app and configure:
Create app: https://developers.kite.trade/create
api_keyapi_secretRedirect URL (example):
http://127.0.0.1:6583/callback
Redirect URL Scenarios
1. Everything runs on your laptop (recommended)
Use this redirect URL:
http://127.0.0.1:6583/callback
Why:
127.0.0.1does not change across networks.- No extra networking setup required.
2. zerokite auth runs on a separate server with static public IP
Use this redirect URL:
http://<static_ip>:6583/callback
Example:
http://203.0.113.10:6583/callback
3. zerokite auth runs on a separate server with dynamic IP (Tailscale)
Use Tailscale so the server gets a stable private identity inside your tailnet.
Steps:
- Install and sign in to Tailscale on the auth server.
- Install and sign in to Tailscale on the machine where you open the login URL (for example, your laptop browser).
- Verify both are in the same tailnet.
- On the auth server, get its Tailscale IP:
tailscale ip -4- Set Kite app redirect URL to:
http://<tailscale_ip>:6583/callback
- Set
KITE_REDIRECT_URLon the auth server to that same value. - Run
zerokite authon the auth server. - Open the printed Kite login URL from a browser that is also connected to the same tailnet.
If MagicDNS is enabled in your tailnet, you can use http://<device-name>.<tailnet>.ts.net:6583/callback instead of the IP.
Set environment variables:
export KITE_API_KEY="your_api_key"
export KITE_API_SECRET="your_api_secret"
export KITE_REDIRECT_URL="http://127.0.0.1:6583/callback"Authentication Flow
zerokite auth starts a temporary callback server and waits for Kite to redirect back with a request_token.
Default port is 6583. Use -p or --port only when you need a different port.
zerokite authIf you change the port, your app's configured redirect URL must use that same port.
For localhost redirect URLs, zerokite listens on 127.0.0.1. For non-localhost redirect URLs, it listens on all interfaces (0.0.0.0).
zerokite login is an alias of zerokite auth.
On success, access_token is stored at:
~/.zerokite/session.json
Commands
zerokite helpzerokite versionzerokite completion <bash|zsh>zerokite auth [-p <port>]zerokite loginzerokite verifyzerokite profilezerokite holdings(includes available funds from margins)zerokite positions [--day|--net]zerokite orders listzerokite orders place ...zerokite orders modify --order_id <id> ...zerokite orders cancel --order_id <id>- Add
--jsonto any command for machine-readable output
Examples
# verify current token
zerokite verify
# holdings + available funds
zerokite holdings
# positions
zerokite positions --net
zerokite positions --day
# list orders
zerokite orders list
# place a regular market order
zerokite orders place \
--variety regular \
--exchange NSE \
--tradingsymbol INFY \
--transaction_type BUY \
--quantity 1 \
--order_type MARKET \
--product CNCDocumentation
Detailed docs are available in /docs:
