listCoinTickers method

Future<CoinGeckoResult<List<Ticker>>> listCoinTickers({
  1. required String id,
  2. List<String> exchangeIds = const [],
  3. int page = 1,
  4. String order = TickersOrder.trustScoreDescending,
  5. bool depth = true,
})

Get coin tickers (paginated to 100 items).

id sets coin id.

exchangeIds filters results by exchange ids.

includeExchangeLogo sets whether to include exchange logo. Default is true.

page sets page through results. Default is 1.

order sets tickers order. Use TickersOrder enumeration as values. Default is TickersOrder.trustScoreDescending.

depth sets whether to include 2% orderbook depth. Default is true.

Query: /coins/{id}/tickers

Implementation

Future<CoinGeckoResult<List<Ticker>>> listCoinTickers({
  required String id,
  List<String> exchangeIds = const [],
  bool includeExchangeLogo = true,
  int page = 1,
  String order = TickersOrder.trustScoreDescending,
  bool depth = true,
}) async {
  final response = await _dio.get(
    '/coins/$id/tickers',
    queryParameters: {
      'id': id,
      'exchange_ids': exchangeIds,
      'include_exchange_logo': includeExchangeLogo,
      'page': page,
      'order': order,
      'depth': depth,
    },
  );
  if (response.statusCode == 200) {
    final jsonTickers = Convert.toListN(response.data['tickers']);
    final List<Ticker> tickers = jsonTickers != null
        ? jsonTickers.map((e) => Ticker.fromJson(e)).toList()
        : [];
    return CoinGeckoResult(tickers);
  } else {
    return CoinGeckoResult(
      [],
      errorCode: response.statusCode ?? null,
      errorMessage: '${response.statusMessage} - ${response.data.toString()}',
      isError: true,
    );
  }
}