listMarketIndexes method
List all market indexes.
itemsPerPage
sets total results per page.
page
sets page through results.
Query path: /indexes
Implementation
Future<CoinGeckoResult<List<MarketIndexIdentified>>> listMarketIndexes({
int? itemsPerPage,
int? page,
}) async {
final Map<String, dynamic> queryParameters = {};
if (itemsPerPage is int) {
queryParameters['per_page'] = itemsPerPage;
}
if (page is int) {
queryParameters['page'] = page;
}
final response = await _client.dio.get(
'/indexes',
queryParameters: queryParameters,
);
if (response.statusCode == 200) {
final data = Convert.toList(response.data, []);
final list = data.map((e) => MarketIndexIdentified.fromJson(e)).toList();
return CoinGeckoResult(list);
} else {
return CoinGeckoResult(
[],
errorCode: response.statusCode ?? null,
errorMessage: '${response.statusMessage} - ${response.data.toString()}',
isError: true,
);
}
}