coingecko_api 2.0.1 copy "coingecko_api: ^2.0.1" to clipboard
coingecko_api: ^2.0.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.');
  }
}
25
likes
150
points
65
downloads

Publisher

unverified uploader

Weekly Downloads

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, dio_smart_retry, intl

More

Packages that depend on coingecko_api