coingecko_api 1.1.1+1 copy "coingecko_api: ^1.1.1+1" to clipboard
coingecko_api: ^1.1.1+1 copied to clipboard

Dart package that provides simple access to the CoinGecko API (Version 3)

example/main.dart

import 'package:coingecko_api/coingecko_api.dart';

Future<void> main() async {
  print(
    'This example demonstrates receiving OHLC data (open, high, low, close) '
    'from CoinGecko on the BTC/USD pair for the last 7 days.',
  );
  final api = CoinGeckoApi();
  print('Calling method getCoinOHLC() ...');
  final result = await api.coins.getCoinOHLC(
    id: 'bitcoin',
    vsCurrency: 'usd',
    days: 7,
  );
  if (!result.isError) {
    print('getCoinOHLC() results:');
    result.data.forEach(
      (item) => print(
          '${item.timestamp}: open = ${item.open}, high = ${item.high}, low = ${item.low}, close = ${item.close}'),
    );
    print('Test method completed successfully.');
  } else {
    print('getCoinOHLC() method returned error:');
    print('${result.errorCode}: ${result.errorMessage}');
    print('Test method failed.');
  }
}
23
likes
130
pub points
74%
popularity

Publisher

unverified uploader

Dart package that provides simple access to the CoinGecko API (Version 3)

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio, intl

More

Packages that depend on coingecko_api