T-Invest Node SDK Node.js

Find an instrument and get its UID

To get a UID from a ticker, also supply the instrument class, classCode. The example finds the SBER share in the TQBR class and prints its UID. Replace the token, ticker, and class with your own values.

instrument-lookup.ts
import { InstrumentIdType, TInvestNodeSDK } from '@woodger/t-invest-node-sdk';

const sdk = new TInvestNodeSDK({
  token: 'YOUR_TOKEN',
  endpoint: 'invest-public-api.tbank.ru:443'
});

try {
  const { instrument } = await sdk.instruments.getInstrumentBy({
    idType: InstrumentIdType.INSTRUMENT_ID_TYPE_TICKER,
    id: 'SBER',
    classCode: 'TQBR'
  });

  if (!instrument) {
    throw new Error('Instrument was not returned');
  }

  console.log(instrument.uid);
}
finally {
  sdk.close();
}

Pass instrument.uid as instrumentId in market data and order requests. The instrument object also exposes the lot size (lot), currency (currency), and price increment (minPriceIncrement) used to place an order in the sandbox.

If you know only part of the name or ticker, start with sdk.instruments.findInstrument({ query }). See the instrument contracts for request parameters and the unary request guide for deadlines.