Skip to content

Dhan CLI

A cross-platform .NET 10 command-line client for the DhanHQ API v2. Binary name: dhan. Windows-first, with first-class macOS and Linux builds.

The Dhan CLI wraps auth, funds, portfolio, orders, trades, super orders, alerts, the instrument master, quotes, historical candles, option chain, margins, eDIS, kill switch / P&L-based exits, IP whitelisting, and US Global Stocks — all in one self-contained binary.

Terminal window
# 1. Bring your own access token (simplest, recommended for terminal agents)
dhan auth configure --client-id <client-id> --access-token <access-token> --json --no-color
dhan auth status --json --no-color
# 2. Read-only sanity checks
dhan account profile --json --no-color
dhan account funds --json --no-color
dhan portfolio holdings --json --no-color
dhan orders list --json --no-color
dhan trades list --json --no-color
# 3. Place a live order — always dry-run first
dhan orders place --file order.json --dry-run --json --no-color
dhan orders place --file order.json --yes --json --no-color
# 4. Resolve a security ID for quotes / historical
dhan instruments download --segment NSE_EQ --json --no-color
dhan instruments search INFY --segment NSE_EQ --json --no-color
  • Install — one-line install on macOS / Linux / Windows.
  • Concepts--json / --no-color contract, exit codes, secret store.
  • Security — no telemetry, OS keyring only, transcript hygiene.
  • Terminal agent guide — operating rules for agents driving the CLI.