API Reference / Instruments
Class: Instruments
Defined in: src/resources/Instruments.ts:72
Segment-wise instrument (scrip master) lookups.
GET /v2/instrument/{segment} returns CSV, not JSON, and a single segment can run to hundreds of thousands of rows — so parsed segments are cached in memory and every lookup goes through that cache.
Constructors
Constructor
new Instruments(
httpClient,config?):Instruments
Defined in: src/resources/Instruments.ts:77
Parameters
httpClient
config?
InstrumentsConfig = {}
Returns
Instruments
Methods
bySegment()
bySegment(
exchangeSegment):Promise<Instrument[]>
Defined in: src/resources/Instruments.ts:85
Every instrument in a segment, cached for InstrumentsConfig.cacheTtlMs.
Parameters
exchangeSegment
string
Returns
Promise<Instrument[]>
clearCache()
clearCache(
exchangeSegment?):void
Defined in: src/resources/Instruments.ts:112
Drops cached segments so the next lookup re-downloads.
Parameters
exchangeSegment?
string
Returns
void
find()
find(
exchangeSegment,symbol,options?):Promise<Instrument|undefined>
Defined in: src/resources/Instruments.ts:128
First instrument in a segment matching symbol.
Equities are matched on UNDERLYING_SYMBOL when present, indices and derivatives on SYMBOL_NAME, which is what makes find("IDX_I", "NIFTY") and find("NSE_EQ", "RELIANCE") both resolve.
Parameters
exchangeSegment
string
symbol
string
options?
InstrumentSearchOptions = ...
Returns
Promise<Instrument | undefined>
findBySecurityId()
findBySecurityId(
exchangeSegment,securityId):Promise<Instrument|undefined>
Defined in: src/resources/Instruments.ts:139
Instrument with this security id inside a segment.
Parameters
exchangeSegment
string
securityId
string | number
Returns
Promise<Instrument | undefined>
search()
search(
query,options?):Promise<Instrument[]>
Defined in: src/resources/Instruments.ts:154
Search across several segments at once, returning up to limit matches. Used by the dhan_search_instruments agent tool to resolve a free-text symbol to a security id.
Parameters
query
string
options?
InstrumentSearchOptions & object = {}
Returns
Promise<Instrument[]>
findAnywhere()
findAnywhere(
symbol,options?):Promise<Instrument|undefined>
Defined in: src/resources/Instruments.ts:180
First match for symbol across segments, in the order given.
Parameters
symbol
string
options?
InstrumentSearchOptions & object = {}
Returns
Promise<Instrument | undefined>