T-Invest Node SDK Node.js

Paginate operations

getOperationsByCursor returns account history in pages. Start with an empty cursor and pass nextCursor to the next request while hasNext is true. Supply your token, account ID, and date range.

operations-pagination.ts
import { TInvestNodeSDK } from '@woodger/t-invest-node-sdk';

const sdk = new TInvestNodeSDK({
  token: 'YOUR_TOKEN',
  endpoint: 'invest-public-api.tbank.ru:443'
});
const request = {
  accountId: 'YOUR_ACCOUNT_ID',
  from: new Date('2026-01-01T00:00:00Z'),
  to: new Date('2026-02-01T00:00:00Z'),
  limit: 100
};
let cursor = '';

try {
  while (true) {
    const page = await sdk.operations.getOperationsByCursor({
      ...request,
      cursor
    });

    for (const operation of page.items) {
      console.log(operation);
    }

    if (!page.hasNext) {
      break;
    }

    cursor = page.nextCursor;
  }
}
finally {
  sdk.close();
}

Keep the account, date range, and filters the same across pages and update only the cursor. Use hasNext to determine when to stop, including when items is empty. The example uses a page size of 100. See the provider documentation for method behavior and the operations contract for filters. In the sandbox, use sdk.sandbox.getSandboxOperationsByCursor.

For many pages, use a request rate limiter. The unary request guide shows how to set a deadline or cancel a call.