tbank_invest 0.1.1
tbank_invest: ^0.1.1 copied to clipboard
Dart client for T-Bank T-Invest: REST (Dio) + WebSocket (dart:io). Unofficial; not for Flutter Web.
// 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 json = await client.users.getAccounts({});
print(json);
} on InvestApiException catch (e) {
print('API error: $e');
} finally {
client.close();
}
}