-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmansaapi_example.dart
More file actions
35 lines (30 loc) · 1.14 KB
/
Copy pathmansaapi_example.dart
File metadata and controls
35 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// ignore_for_file: avoid_print
import 'package:mansaapi/mansaapi.dart';
Future<void> main() async {
final mansa = MansaAPI(apiKey: 'mansa_live_sk_your_key_here');
try {
// Top movers across all live African exchanges.
final movers = await mansa.markets.getPanAfricanMovers(limit: 5);
for (final mover in (movers['gainers'] as List<dynamic>)) {
final m = mover as Map<String, dynamic>;
print('${m['ticker']} (${m['exchange']}): ${m['change_pct']}%');
}
// Is the Nigerian Exchange open right now?
final status = await mansa.markets.isOpen('NGX');
print('NGX open: ${status['is_open']} (${status['status']})');
// Central bank policy rates across Africa.
final rates = await mansa.macro.getPolicyRates();
for (final row in rates) {
final r = row as Map<String, dynamic>;
print('${r['country_name']}: ${r['policy_rate']}% '
'(inflation ${r['inflation_yoy']}%)');
}
} on MansaAPIException catch (error) {
print('Mansa API error [${error.code}]: ${error.message}');
if (error.hint != null) {
print('Hint: ${error.hint}');
}
} finally {
mansa.close();
}
}