getDerivativeExchange method

Future<CoinGeckoResult<DerivativeExchangeExtended?>> getDerivativeExchange({
  1. required String id,
  2. String? includeTickers,
})

Show derivative exchange data.

id sets the exchange identifier.

includeTickers filters tickers by expiration. Use DerivativeTickersFilter enumeration as values. If null, tickers data in response will be omitted.

Query: /derivatives/exchanges/{id}

Implementation

Future<CoinGeckoResult<DerivativeExchangeExtended?>> getDerivativeExchange({
  required String id,
  String? includeTickers,
}) async {
  final response = await _dio.get(
    '/derivatives/exchanges/$id',
    queryParameters: {
      'include_tickers': includeTickers,
    },
  );
  if (response.statusCode == 200) {
    final data = DerivativeExchangeExtended.fromJson(response.data);
    return CoinGeckoResult(data);
  } else {
    return CoinGeckoResult(
      null,
      errorCode: response.statusCode ?? null,
      errorMessage: '${response.statusMessage} - ${response.data.toString()}',
      isError: true,
    );
  }
}