listPrices method
Get the current price of any cryptocurrencies in any other supported currencies that you need.
ids
sets identifiers of coins.
vsCurrencies
sets vs currency of coins.
includeMarketCap
sets whether to include market capitalization.
Default is false.
include24hVol
sets whether to include volume in 24 hours.
Default is false.
include24hChange
sets whether to include change in 24 hours.
Default is false.
includeLastUpdatedAt
sets whether to include last updated date.
Default is false.
Query path: /simple/price
Implementation
Future<CoinGeckoResult<List<PriceInfo>>> listPrices({
required List<String> ids,
required List<String> vsCurrencies,
bool includeMarketCap = false,
bool include24hVol = false,
bool include24hChange = false,
bool includeLastUpdatedAt = false,
}) async {
final response = await _client.dio.get(
'/simple/price',
queryParameters: {
'ids': ids.join(','),
'vs_currencies': vsCurrencies.join(','),
'include_market_cap': includeMarketCap,
'include_24hr_vol': include24hVol,
'include_24hr_change': include24hChange,
'include_last_updated_at': includeLastUpdatedAt
},
);
if (response.statusCode == 200) {
List<PriceInfo> priceInfo = [];
final map = Convert.toMapN<String, dynamic>(response.data);
if (map != null) {
map.forEach((key, value) {
priceInfo.add(PriceInfo.fromJson(key, value));
});
}
return CoinGeckoResult(priceInfo);
} else {
return CoinGeckoResult(
[],
errorMessage: response.data.toString(),
errorCode: response.statusCode ?? null,
isError: true,
);
}
}