getContractMarketChartRanged method
Get historical market data including price, market cap, and 24h volume within a range of timestamps (granularity auto) from a contract address.
id
sets the id of the platform issuing tokens.
contractAddress
is token's contract address.
vsCurrency
sets the target currency of market data (usd, eur, jpy, etc.).
from
sets FROM date.
to
sets TO date.
Query path: /coins/{id}/contract/{contract_address}/market_chart/range
Implementation
Future<CoinGeckoResult<List<MarketChartData>>> getContractMarketChartRanged({
required String id,
required String contractAddress,
required String vsCurrency,
required DateTime from,
required DateTime to,
}) async {
final response = await _client.dio.get(
'/coins/$id/contract/$contractAddress/market_chart/range',
queryParameters: {
'vs_currency': vsCurrency,
'from': from.millisecondsSinceEpoch ~/ 1000,
'to': to.millisecondsSinceEpoch ~/ 1000,
},
);
if (response.statusCode == 200) {
final list = Helpers.parseMarketChartData(response.data);
return CoinGeckoResult(list);
} else {
return CoinGeckoResult(
[],
errorCode: response.statusCode ?? null,
errorMessage: '${response.statusMessage} - ${response.data.toString()}',
isError: true,
);
}
}