T-Invest Node SDK Node.js
En esta página

Ejecutar un comando de la CLI

El módulo incluye su propia interfaz de línea de comandos (CLI). Puedes consultar datos, gestionar órdenes y suscribirte a flujos desde la terminal sin escribir código.

Consultar la lista de cuentas con la CLI

Instala el módulo y obtén un token de la API de producción con permiso de lectura de cuentas. En Bash, read lee el token sin mostrarlo en pantalla. Instalar el SDK · Obtener un token de T-Bank

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

Comando salidas JSON-matriz de cuentas. Así es como se ve el resultado con los datos de una cuenta condicional.

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

Si no hay un token disponible, CLI salidas [] con el código de finalización 0. Para el sandbox, configure la dirección sandbox-invest-public-api.tbank.ru:443 y el token de sandbox, luego use sandbox account list --format=json.

Seleccionar comando y obtener ayuda

Comando La ruta comienza con el dominio y puede incluir un subgrupo. Por ejemplo, instrument bond list muestra una lista de bonos. Se puede abrir ayuda para todos CLI, dominio o comando individual.

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

Pase la conexión y los argumentos

Para los comandos que necesitan SDK, pase los parámetros de conexión a través de --token / T_INVEST_TOKEN y --endpoint /T_INVEST_ENDPOINT.

Pase las opciones lógicas como banderas (--raw y si la opción admite anulación negativa, --no-raw), no hay formulario --raw=true y --raw=false. Las opciones de enteros positivos deben encajar en un rango seguro JavaScript. Para las fechas, utilice RFC 3339 con Z explícito o desfase de zona horaria numérica.

Comprobar el código de finalización

CLI Escribe el resultado en stdout y los diagnósticos en stderr. El código de finalización indica si se ejecutó el comando.

  • 0 - El equipo se completó con éxito;
  • 2 Error de llamada: comando desconocido, argumentos incorrectos, falta de un valor obligatorio de CLI o configuración de comando incorrecta;
  • 1 - Error de ejecución, proveedor, sistema de archivos, salida o definición de comando interno.

Señales de proceso de completar el flujo se describen en Referencia de corriente CLI.

Seleccionar comando o ruta compatible

Los nombres básicos son adecuados para nuevos scripts. Para encontrar un nombre del script antiguo, expanda la lista de alias para el grupo deseado.

Cuentas y tarifas

Solicitar cuentas disponibles, información del usuario, indicadores de margen o cuotas arancelarias.

Comando Método SDK
account list sdk.users.getAccounts
account info sdk.users.getInfo
account margin sdk.users.getMarginAttributes
account tariff sdk.users.getUserTariff
Comando Alias para cuentas
Nombres compatibles Equipo
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

Herramientas

Busque la herramienta Ticker, obtenga datos de clase de activos o consulte el cronograma de negociación.

Comando Método SDK
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
Alias de comando para instrumentos
Nombres compatibles Equipo
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

Datos de mercado

Obtenga velas, precios, oficios impersonales, vidrio o estado comercial.

Comando Método SDK
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
ALIAS DE DATOS DE MERCADO
Nombres compatibles Equipo
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

Portafolio, operaciones e informes

Obtenga posiciones o cartera, lea las operaciones del cursor o solicite un informe.

Comando Método SDK
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
Alias de comandos para operaciones
Nombres compatibles Equipo
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

Aplicaciones y detener aplicaciones

Estos comandos leen el estado de las aplicaciones y manejarlos. En la configuración estándar, los cambios requieren confirmación. Confirmación de comando

Comandos order show y sandbox order show aceptan el parámetro opcional --order-date con la fecha y hora del pedido en formato RFC 3339, por ejemplo --order-date 2026-11-30T09:30:00Z.

Comando Método SDK
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
Comandos de alias para pedidos
Nombres compatibles Equipo
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

Abrir cuenta de prueba, recibir sus datos o realizar Operaciones con aplicaciones de prueba. Ejemplo de trabajo de caja de arena

Comando Método SDK
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
Alias de comando para sandbox
Nombres compatibles Equipo
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, desarrollo y ayuda

Las suscripciones de stream están configuradas en JSON. Se necesita generación de contratos cuando se trabaja con fuentes SDK.

Comando Asignar
stream run Ejecutar stream por Archivo de configuración
dev compile-proto Generar contratos TypeScript
help Abrir ayuda en CLI, dominio o comando
version Averiguar
Comando de generación alias
Nombres compatibles Equipo
compile-proto dev compile-proto

Confirmar Comando con efecto secundario

Los comandos que cambian las órdenes, los favoritos o las cuentas sandbox requieren --confirm de forma predeterminada. Esto es responsable de defaultConfig.requireSideEffectConfirmation.

CLI no genera automáticamente claves de idonetencia: order place acepta --order-id pero order replace — --idempotency-key.

sandbox pay-in acepta --currency=rub|usd. CLI Rechaza los valores de moneda desconocidos y para un proveedor no compatible --currency=usd El comando devuelve un error.

Ejecutar comando de transmisión

Para la transmisión API hay un comando separado stream run --config=PATH. Las suscripciones de larga duración, la finalización del proceso y el formato de evento se describen en Referencia de corriente CLI y Directorio de su configuración.

Público CLI no agrega un comando para los métodos generados heredados:

  • sdk.instruments.options - obsoleto en el contrato generado; En cambio, se usa instrument option list / sdk.instruments.optionsBy.

Compatibilidad --figi y campos de riesgo se describen en el manual Campos desactualizados del proveedor.