tbank_invest 0.6.4 copy "tbank_invest: ^0.6.4" to clipboard
tbank_invest: ^0.6.4 copied to clipboard

T-Invest (T-Bank) Invest API: fully typed REST (V1* DTOs), WebSocket (dart:io), OpenAPI codegen, optional hand helpers. Unofficial. Not for Flutter Web.

example/example.dart

// ignore_for_file: avoid_print

/// Minimal example: sandbox [GetAccounts] (requires a real sandbox token).
///
/// From package root:
/// `dart run --define=TBANK_TOKEN=t.xxx example/example.dart`
library;

import 'package:tbank_invest/tbank_invest.dart';

Future<void> main() async {
  const token = String.fromEnvironment('TBANK_TOKEN', defaultValue: '');
  if (token.isEmpty) {
    print(
        'Set token: dart run --define=TBANK_TOKEN=t.xxx example/example.dart');
    return;
  }

  final client = TinvestClient(
    InvestConfig(
      token: token,
      environment: InvestEnvironment.sandbox,
    ),
  );

  try {
    final response =
        await client.users.getAccounts(const V1GetAccountsRequest());
    final accounts = response.accounts ?? <V1Account>[];
    print('Accounts: ${accounts.length}');
    for (final account in accounts) {
      final status = account.status?.name ?? 'n/a';
      print('- ${account.id} ${account.name ?? ''} ($status)');
    }
  } on InvestApiException catch (e) {
    print('API error: $e');
  } finally {
    client.close();
  }
}
1
likes
150
points
216
downloads

Documentation

Documentation
API reference

Publisher

verified publisherkriuchkov.dev

Weekly Downloads

T-Invest (T-Bank) Invest API: fully typed REST (V1* DTOs), WebSocket (dart:io), OpenAPI codegen, optional hand helpers. Unofficial. Not for Flutter Web.

Repository (GitHub)
View/report issues
Contributing

Topics

#invest #tbank #trading #dio #websocket

License

MIT (license)

Dependencies

collection, dio, json_annotation, meta

More

Packages that depend on tbank_invest