T-Invest Node SDK Node.js
Auf dieser Seite

CLI-Befehl ausführen

Das Modul hat eine eigene Kommandozeilenschnittstelle (CLI). Damit können Sie direkt im Terminal Daten abrufen, Aufträge verwalten und Streams abonnieren, ohne Code zu schreiben.

Konten über die CLI abrufen

Installieren Sie das Modul und erstellen Sie ein Token für die Produktions-API mit Lesezugriff auf die Konten. In Bash nimmt read das Token entgegen, ohne es anzuzeigen. SDK installieren · Token der T-Bank erstellen

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

Der Befehl druckt ein JSON-Array von Konten. In diesem Beispiel werden Beispieldaten für ein Konto verwendet.

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": ""
  }
]

Wenn das Token Zugriff auf keine Konten hat, druckt das CLI [] und beendet mit Code 0. Setzen Sie für die Sandbox den Endpunkt auf sandbox-invest-public-api.tbank.ru:443, verwenden Sie ein Sandbox-Token und führen Sie sandbox account list --format=json aus.

Befehl auswählen und Hilfe anzeigen

Der Befehlspfad beginnt mit einer Domäne und kann eine Untergruppe enthalten. Zum Beispiel instrument bond list listet Anleihen auf. Holen Sie sich Hilfe für den CLI, eine Domäne oder einen einzelnen Befehl.

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

Verbindungseinstellungen und Argumente übergeben

Für Befehle, die das SDK benötigen, stellen Sie die Verbindungsparameter über --token oder T_INVEST_TOKEN und --endpoint oder T_INVEST_ENDPOINT.

Übergeben Sie boolesche Optionen als Flags wie --raw und, wo unterstützt, --no-raw. Die Formulare --raw=true und --raw=false werden nicht unterstützt. Positive Ganzzahloptionen müssen in den sicheren Ganzzahlbereich JavaScript passen. Verwenden Sie RFC 3339-Daten mit einem expliziten Z- oder numerischen Zeitzonen-Offset.

Exit-Code prüfen

die CLI schreibt die Ausgabe in stdout und die Diagnose in stderr. Der Exit-Code meldet das Ergebnis.

  • 0 — Erfolg.
  • 2 – Aufruffehler, wie ein unbekannter Befehl, ungültige Argumente, fehlende erforderliche CLI- oder Umgebungswerte oder ungültige Befehlskonfiguration.
  • 1 — Laufzeit, Anbieter, Dateisystem, Ausgabe oder interner Befehlsdefinitionsfehler.

Siehe Streaming CLI Referenz für die Terminierung durch Prozesssignale.

Befehl oder kompatiblen Alias wählen

Verwenden Sie die primären Namen in neuen Skripten. Um einen Namen aus einem älteren Skript nachzuschlagen, erweitern Sie die Aliase für diese Gruppe.

Konten und Kontingente

Rufen Sie zugängliche Konten, Benutzerinformationen, Margendetails oder Tarifkontingente ab.

Befehl SDK-Methode
account list sdk.users.getAccounts
account info sdk.users.getInfo
account margin sdk.users.getMarginAttributes
account tariff sdk.users.getUserTariff
Account-Befehls-Aliase
Aliase Befehl
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

Instrumente

Suchen Sie ein Instrument nach Ticker, suchen Sie nach einer Anlageklasse oder überprüfen Sie die Handelspläne.

Befehl SDK-Methode
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
Instrumentalbefehls-Aliase
Aliase Befehl
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

Marktdaten

Rufen Sie Kerzen, Preise, letzte Trades, das Orderbuch oder den Handelsstatus ab.

Befehl SDK-Methode
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
Marktdaten-Kommando-Aliase
Aliase Befehl
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, Betrieb und Berichte

Abrufen von Positionen oder einem Portfolio, Seite durch Operationen oder einen Bericht anfordern.

Befehl SDK-Methode
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
Operationsbefehl-Aliase
Aliase Befehl
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

Bestellungen und Stop-Bestellungen

Diese Befehle überprüfen und verwalten Bestellungen. Bei der Standardkonfiguration müssen Änderungen bestätigt werden. Bestätigen Sie einen Befehl

order show und sandbox order show Akzeptieren Sie ein optionales --order-date-Argument für das Datum und die Uhrzeit der Bestellung. Verwenden Sie RFC 3339, zum Beispiel --order-date 2026-11-30T09:30:00Z.

Befehl SDK-Methode
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
Befehls-Aliase
Aliase Befehl
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

Öffnen Sie ein Testkonto, lesen Sie die Daten oder arbeiten Sie mit Testaufträge. Sandbox-Beispiel

Befehl SDK-Methode
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-Befehls-Aliase
Aliase Befehl
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, Entwicklung und Hilfe

Stream-Abonnements in definieren JSON. Generieren Sie Verträge, wenn Sie an der SDK-Quelle arbeiten.

Befehl Beschreibung
stream run Führen Sie einen Stream von a Konfigurationsdatei
dev compile-proto Generieren TypeScript Verträge
help Hilfe für den Befehl CLI, eine Domäne oder einen Befehl anzeigen
version Paketversion anzeigen
Vertragsgenerierungsbefehl Alias
Aliase Befehl
compile-proto dev compile-proto

Befehl mit Zustandsänderung bestätigen

Befehle, die die Bestellungen, Favoriten oder Sandbox-Konten ändern, erfordern standardmäßig --confirm. defaultConfig.requireSideEffectConfirmation Steuert dieses Verhalten.

Geben Sie Ihre eigenen Idempotenz-Schlüssel an. order place Nimmt --order-id und order replace --idempotency-key.

sandbox pay-in Akzeptiert --currency=rub|usd. Das CLI lehnt unbekannte Werte ab und gibt einen Fehler zurück, wenn der Anbieter --currency=usd nicht unterstützt.

Streaming-Befehl ausführen

Verwenden Sie stream run --config=PATH für das Streaming API. In den Formaten Streaming CLI Referenz und Konfigurationsreferenz finden Sie lange Abonnements, Prozessbeendigungen und Ereignisformate.

Verwenden Sie aktuelle Methoden in der Öffentlichkeit CLI.

  • sdk.instruments.options ist im generierten Vertrag veraltet. Verwenden Sie instrument option list / sdk.instruments.optionsBy.

Siehe Veraltete Anbieterfelder für --figi und Risikofeldkompatibilität.