Skip to main content

Kite Connect CLI — Multi-account Zerodha trading positions viewer

Project description

KCLI — Kite Connect CLI

A multi-account Zerodha Kite Connect positions viewer with a beautiful terminal interface.

  ╦╔═╔═╗╦  ╦
  ╠╩╗║  ║  ║
  ╩ ╩╚═╝╩═╝╩
  Kite Connect CLI

Architecture

┌─────────────────┐       HTTPS       ┌──────────────────┐      Kite API      ┌─────────────────┐
│   kcli (CLI)    │ ──────────────── │  FastAPI Server  │ ──────────────────│  Zerodha Kite   │
│   Your Machine  │                   │  Google Cloud    │                    │  Connect API    │
└─────────────────┘                   └──────────────────┘                    └─────────────────┘
        │
        ▼
  ~/.kcli/config.yaml
  • CLI (kcli): Runs on your machine. Beautiful color-coded terminal UI.
  • Server: Runs on Google Cloud (Cloud Run). Proxies Kite API calls.
  • Config: Multi-account config stored locally at ~/.kcli/config.yaml.

Quick Start

1. Deploy the Server

# Build and deploy to Cloud Run
cd server
gcloud run deploy kcli-server \
  --source . \
  --region asia-south1 \
  --allow-unauthenticated \
  --set-env-vars AUTH_TOKEN=your-secret-token

2. Install the CLI

# From the project root
pip install -e .

3. Initialize Config

# Create the default config file
kcli config --init

# Edit the config with your accounts
# Open ~/.kcli/config.yaml and add your Kite API credentials

Config file format (~/.kcli/config.yaml):

server:
  url: "https://your-cloud-run-url.run.app"
  auth_token: "your-secret-token"

accounts:
  - name: "Trading Account 1"
    api_key: "your_api_key_1"
    api_secret: "your_api_secret_1"
  - name: "Trading Account 2"
    api_key: "your_api_key_2"
    api_secret: "your_api_secret_2"

4. Login to Kite

# Initialize and authenticate all accounts
kcli init

This will:

  1. Send your account configs to the server
  2. Display login URLs for each account
  3. Prompt you to paste the request_token after logging in via browser

Note: Kite access tokens expire daily (~6 AM IST). You need to run kcli init once each trading day.

5. View Positions

# View positions across all accounts
kcli positions

Commands

Command Description
kcli init Authenticate all accounts (daily)
kcli positions View positions across all accounts
kcli status Check authentication status
kcli config --init Create default config file
kcli config --show Show current config (secrets masked)
kcli config --path Print config file path

Development

Run Server Locally

cd server
pip install -r requirements.txt
AUTH_TOKEN=test-token uvicorn main:app --reload --port 8080

Run CLI

pip install -e .
kcli --help

Getting Kite API Credentials

  1. Go to Kite Developer Console
  2. Create a new app
  3. Note your API Key and API Secret
  4. Set the Redirect URL to your server's callback URL

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kitecli-0.1.0b1.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kitecli-0.1.0b1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file kitecli-0.1.0b1.tar.gz.

File metadata

  • Download URL: kitecli-0.1.0b1.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for kitecli-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 ef137d89cf6625cdbecb36830a27161b0c3c3d7a278dc2b5b477c54761b46333
MD5 f5c100a7169624abd9f9f354d892689b
BLAKE2b-256 f61ce04bdd4a0bb60f7b5be52f0909dc9028f891a61cdda4424be41a307ca72b

See more details on using hashes here.

File details

Details for the file kitecli-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: kitecli-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for kitecli-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5c07d82e576e50033b1fb1e2072f4c84856482af1a49f05c54eac7856ea0391
MD5 509a5acedaaf8e383afc6f2b46ec25b5
BLAKE2b-256 f7d6c5c86d6bbe1133077d820810fa3e317f6e36e716cd813488152971935120

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page