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.
Quick start
Section titled “Quick start”# 1. Bring your own access token (simplest, recommended for terminal agents)dhan auth configure --client-id <client-id> --access-token <access-token> --json --no-colordhan auth status --json --no-color
# 2. Read-only sanity checksdhan account profile --json --no-colordhan account funds --json --no-colordhan portfolio holdings --json --no-colordhan orders list --json --no-colordhan trades list --json --no-color
# 3. Place a live order — always dry-run firstdhan orders place --file order.json --dry-run --json --no-colordhan orders place --file order.json --yes --json --no-color
# 4. Resolve a security ID for quotes / historicaldhan instruments download --segment NSE_EQ --json --no-colordhan instruments search INFY --segment NSE_EQ --json --no-colorReference by command group
Section titled “Reference by command group”auth
Configure, browser consent, TOTP, partner login, consume, renew, logout.
config
Non-secret preferences (config.json) — baseUrl, redirectPort.
account
Profile, funds, ledger.
portfolio
Holdings, positions, convert, exit-all. Live action
orders
Place / modify / cancel / slice / list / correlation. Live action
trades
Trades and historical trades.
super
Super Orders. Live action
alerts
Conditional triggers. Live action
quote
LTP / OHLC / full quote — numeric security IDs. Needs Dhan Data API.
historical
Daily / intraday / rolling-option candles.
option-chain
Expiry list and option chain. Needs Dhan Data API.
margins
Order and multi-order margin calculator (read-only).
edis
eDIS — T-PIN, bulk authorisation form, inquire.
control
Kill switch, P&L-based exit. Live action
global
US Global Stocks orders/trades/holdings/funds/estimate. Live action
ip
Static-IP whitelist — required for live trading.
instruments
Download and search the Dhan instrument master.
raw
Direct escape hatch for unwrapped endpoints.
update
Print the latest release URL.
See also
Section titled “See also”- Install — one-line install on macOS / Linux / Windows.
- Concepts —
--json / --no-colorcontract, exit codes, secret store. - Security — no telemetry, OS keyring only, transcript hygiene.
- Terminal agent guide — operating rules for agents driving the CLI.