Skip to content

dhan instruments

Download and search the Dhan instrument master. The downloaded segment CSV is cached as both .csv and a parsed .json next to it; search reads the JSON.

Subcommand Dhan endpoint Purpose Flags
dhan instruments download --segment <seg> GET instrument/{segment} Download + cache the segment CSV. --segment (req)
dhan instruments search <text> [--segment <seg>] (no API call) Search the cached JSON for matches. Limit 25.
%AppData%\dhan-cli\instruments\<segment>.csv
%AppData%\dhan-cli\instruments\<segment>.json

On macOS / Linux this resolves to the platform application-data folder.

The CSV parser is column-name tolerant — it accepts multiple header spellings (SEM_SMST_SECURITY_ID or SECURITY_ID or SCRIP_CODE; SEM_TRADING_SYMBOL or TRADING_SYMBOL or SYMBOL; etc.) so Dhan’s column renames do not break the cache. The cached row model is CachedInstrument(ExchangeSegment, SecurityId, TradingSymbol, SymbolName, Instrument, Isin).

Terminal window
dhan instruments download --segment NSE_EQ --json --no-color
dhan instruments search INFY --segment NSE_EQ --json --no-color
dhan instruments search 1333 --json --no-color # by security ID

The search text matches security id / trading symbol / symbol name / ISIN (case-insensitive contains). Omitting --segment searches across all cached segments.

  • dhan quote consumes the numeric security ID returned here.