T-Invest Node SDK Node.js
On this page

Run a CLI command

The module has its own command-line interface (CLI). You can query data, manage orders, and subscribe to streams directly from your terminal without writing code.

List accounts with the CLI

Install the package and get a production API token with read access to the accounts. In Bash, read accepts the token without echoing it. Install the SDK · Get a T-Bank token

Shell
read -rsp 'T-Invest token: ' T_INVEST_TOKEN
printf '\n'
export T_INVEST_TOKEN
export T_INVEST_ENDPOINT=invest-public-api.tbank.ru:443

npm exec -- t-invest-node-sdk account list --format=json

The command prints a JSON array of accounts. This example uses sample data for one account.

JSON
[
  {
    "id": "account-id",
    "name": "Main account",
    "type": "ACCOUNT_TYPE_TINKOFF",
    "status": "ACCOUNT_STATUS_OPEN",
    "accessLevel": "ACCOUNT_ACCESS_LEVEL_FULL_ACCESS",
    "openedDate": "2026-06-19T00:00:00.000Z",
    "closedDate": ""
  }
]

If the token has access to no accounts, the CLI prints [] and exits with code 0. For the sandbox, set the endpoint to sandbox-invest-public-api.tbank.ru:443, use a sandbox token, and run sandbox account list --format=json.

Choose a command and get help

The command path starts with a domain and can include a subgroup. For example, instrument bond list lists bonds. Get help for the CLI, a domain, or an individual command.

Shell
npm exec -- t-invest-node-sdk --help
npm exec -- t-invest-node-sdk market --help
npm exec -- t-invest-node-sdk market order-book --help

Pass connection settings and arguments

For commands that need the SDK, supply the connection parameters via --token or T_INVEST_TOKEN and --endpoint or T_INVEST_ENDPOINT.

Pass boolean options as flags, such as --raw and, where supported, --no-raw. The forms --raw=true and --raw=false are unsupported. Positive integer options must fit in the JavaScript safe integer range. Use RFC 3339 dates with an explicit Z or numeric time zone offset.

Check the exit code

The CLI writes output to stdout and diagnostics to stderr. The exit code reports the outcome.

  • 0 — success.
  • 2 — invocation error, such as an unknown command, invalid arguments, a missing required CLI or environment value, or invalid command configuration.
  • 1 — runtime, provider, file system, output, or internal command definition error.

See the streaming CLI reference for termination by process signals.

Choose a command or compatible alias

Use the primary names in new scripts. To look up a name from an older script, expand the aliases for that group.

Accounts and quotas

Retrieve accessible accounts, user information, margin details, or tariff quotas.

Command SDK method
account list sdk.users.getAccounts
account info sdk.users.getInfo
account margin sdk.users.getMarginAttributes
account tariff sdk.users.getUserTariff
Account command aliases
Aliases Command
account get-accounts, users get-accounts account list
account get-info, users get-info account info
account get-margin-attributes, users get-margin-attributes account margin
account get-user-tariff, users get-user-tariff account tariff

Instruments

Find an instrument by ticker, look up an asset class, or check trading schedules.

Command SDK method
instrument search sdk.instruments.findInstrument
instrument show sdk.instruments.getInstrumentBy
instrument dividends sdk.instruments.getDividends
instrument schedules sdk.instruments.tradingSchedules
instrument favorite list sdk.instruments.getFavorites
instrument favorite edit sdk.instruments.editFavorites
instrument share list sdk.instruments.shares
instrument share show sdk.instruments.shareBy
instrument bond list sdk.instruments.bonds
instrument bond show sdk.instruments.bondBy
instrument bond coupons sdk.instruments.getBondCoupons
instrument bond accrued sdk.instruments.getAccruedInterests
instrument etf list sdk.instruments.etfs
instrument etf show sdk.instruments.etfBy
instrument currency list sdk.instruments.currencies
instrument currency show sdk.instruments.currencyBy
instrument future list sdk.instruments.futures
instrument future show sdk.instruments.futureBy
instrument future margin sdk.instruments.getFuturesMargin
instrument option list sdk.instruments.optionsBy
instrument option show sdk.instruments.optionBy
instrument asset list sdk.instruments.getAssets
instrument asset show sdk.instruments.getAssetBy
instrument brand list sdk.instruments.getBrands
instrument brand show sdk.instruments.getBrandBy
instrument country list sdk.instruments.getCountries
Instrument command aliases
Aliases Command
instrument find-instrument, instruments find-instrument instrument search
instrument get-instrument-by, instruments get-instrument-by instrument show
instrument get-dividends, instruments get-dividends instrument dividends
instrument trading-schedules, instruments trading-schedules instrument schedules
instrument get-favorites, instruments get-favorites instrument favorite list
instrument edit-favorites, instruments edit-favorites instrument favorite edit
instrument shares, instruments shares instrument share list
instrument share-by, instruments share-by instrument share show
instrument bonds, instruments bonds instrument bond list
instrument bond-by, instruments bond-by instrument bond show
instrument get-bond-coupons, instruments get-bond-coupons instrument bond coupons
instrument get-accrued-interests, instruments get-accrued-interests instrument bond accrued
instrument etfs, instruments etfs instrument etf list
instrument etf-by, instruments etf-by instrument etf show
instrument currencies, instruments currencies instrument currency list
instrument currency-by, instruments currency-by instrument currency show
instrument futures, instruments futures instrument future list
instrument future-by, instruments future-by instrument future show
instrument get-futures-margin, instruments get-futures-margin instrument future margin
instrument options-by, instruments options-by instrument option list
instrument option-by, instruments option-by instrument option show
instrument get-assets, instruments get-assets instrument asset list
instrument get-asset-by, instruments get-asset-by instrument asset show
instrument get-brands, instruments get-brands instrument brand list
instrument get-brand-by, instruments get-brand-by instrument brand show
instrument get-countries, instruments get-countries instrument country list

Market data

Retrieve candles, prices, last trades, the order book, or trading statuses.

Command SDK method
market candles sdk.marketData.getCandles
market close-prices sdk.marketData.getClosePrices
market last-prices sdk.marketData.getLastPrices
market trades sdk.marketData.getLastTrades
market order-book sdk.marketData.getOrderBook
market status sdk.marketData.getTradingStatus
market statuses sdk.marketData.getTradingStatuses
Market data command aliases
Aliases Command
market get-candles, marketdata get-candles market candles
market get-close-prices, marketdata get-close-prices market close-prices
market get-last-prices, marketdata get-last-prices market last-prices
market get-last-trades, marketdata get-last-trades market trades
market get-order-book, marketdata get-order-book market order-book
market get-trading-status, marketdata get-trading-status market status
market get-trading-statuses, marketdata get-trading-statuses market statuses

Portfolio, operations, and reports

Retrieve positions or a portfolio, page through operations, or request a report.

Command SDK method
operation list sdk.operations.getOperations
operation page sdk.operations.getOperationsByCursor
operation broker-report sdk.operations.getBrokerReport
operation foreign-dividends-report sdk.operations.getDividendsForeignIssuer
operation portfolio sdk.operations.getPortfolio
operation positions sdk.operations.getPositions
operation withdraw-limits sdk.operations.getWithdrawLimits
Operation command aliases
Aliases Command
operation get-operations, operations get-operations operation list
operation get-operations-by-cursor, operations get-operations-by-cursor operation page
operation get-broker-report, operations get-broker-report operation broker-report
operation get-dividends-foreign-issuer, operations get-dividends-foreign-issuer operation foreign-dividends-report
operation get-portfolio, operations get-portfolio operation portfolio
operation get-positions, operations get-positions operation positions
operation get-withdraw-limits, operations get-withdraw-limits operation withdraw-limits

Orders and stop orders

These commands inspect and manage orders. With the default configuration, changes require confirmation. Confirm a command

order show and sandbox order show accept an optional --order-date argument for the date and time the order was placed. Use RFC 3339, for example --order-date 2026-11-30T09:30:00Z.

Command SDK method
order list sdk.orders.getOrders
order show sdk.orders.getOrderState
order place sdk.orders.postOrder
order cancel sdk.orders.cancelOrder
order replace sdk.orders.replaceOrder
stop-order list sdk.stopOrders.getStopOrders
stop-order place sdk.stopOrders.postStopOrder
stop-order cancel sdk.stopOrders.cancelStopOrder
Order command aliases
Aliases Command
order get-orders, orders get-orders order list
order get-order-state, orders get-order-state order show
order post-order, orders post-order order place
order cancel-order, orders cancel-order order cancel
order replace-order, orders replace-order order replace
stop-order get-stop-orders, stoporders get-stop-orders stop-order list
stop-order post-stop-order, stoporders post-stop-order stop-order place
stop-order cancel-stop-order, stoporders cancel-stop-order stop-order cancel

Sandbox

Open a test account, read its data, or work with test orders. Sandbox example

Command SDK method
sandbox account list sdk.sandbox.getSandboxAccounts
sandbox account open sdk.sandbox.openSandboxAccount
sandbox account close sdk.sandbox.closeSandboxAccount
sandbox order list sdk.sandbox.getSandboxOrders
sandbox order show sdk.sandbox.getSandboxOrderState
sandbox order place sdk.sandbox.postSandboxOrder
sandbox order replace sdk.sandbox.replaceSandboxOrder
sandbox order cancel sdk.sandbox.cancelSandboxOrder
sandbox position list sdk.sandbox.getSandboxPositions
sandbox operation list sdk.sandbox.getSandboxOperations
sandbox operation page sdk.sandbox.getSandboxOperationsByCursor
sandbox portfolio sdk.sandbox.getSandboxPortfolio
sandbox withdraw-limits sdk.sandbox.getSandboxWithdrawLimits
sandbox pay-in sdk.sandbox.sandboxPayIn
Sandbox command aliases
Aliases Command
sandbox get-sandbox-accounts sandbox account list
sandbox open-sandbox-account sandbox account open
sandbox close-sandbox-account sandbox account close
sandbox get-sandbox-orders sandbox order list
sandbox get-sandbox-order-state sandbox order show
sandbox post-sandbox-order sandbox order place
sandbox replace-sandbox-order sandbox order replace
sandbox cancel-sandbox-order sandbox order cancel
sandbox get-sandbox-positions sandbox position list
sandbox get-sandbox-operations sandbox operation list
sandbox get-sandbox-operations-by-cursor sandbox operation page
sandbox get-sandbox-portfolio sandbox portfolio
sandbox get-sandbox-withdraw-limits sandbox withdraw-limits
sandbox sandbox-pay-in sandbox pay-in

Streams, development, and help

Define stream subscriptions in JSON. Generate contracts when working on the SDK source.

Command Purpose
stream run Run a stream from a configuration file
dev compile-proto Generate TypeScript contracts
help Show help for the CLI, a domain, or a command
version Show the package version
Contract generation command alias
Aliases Command
compile-proto dev compile-proto

Confirm a command with side effects

Commands that change orders, favorites, or sandbox accounts require --confirm by default. defaultConfig.requireSideEffectConfirmation controls this behavior.

Supply your own idempotency keys. order place takes --order-id, and order replace takes --idempotency-key.

sandbox pay-in accepts --currency=rub|usd. The CLI rejects unknown values and returns an error if the provider does not support --currency=usd.

Run a streaming command

Use stream run --config=PATH for the streaming API. See the streaming CLI reference and the configuration reference for long-running subscriptions, process termination, and event formats.

Use current methods in the public CLI.

  • sdk.instruments.options is deprecated in the generated contract. Use instrument option list / sdk.instruments.optionsBy.

See Deprecated provider fields for --figi and risk field compatibility.