rates-api / src/services/providers/cryptoCompare / CryptoCompare
Defined in: src/services/providers/cryptoCompare.ts:28
Singleton class to interact with the CryptoCompare API.
This class provides methods to retrieve cryptocurrency exchange rates and market data from CryptoCompare. It handles API requests, caching, and rate limiting.
import { CryptoCompare } from './cryptocompare';
async function fetchExchangeRates() {
const cryptoCompare = CryptoCompare.getInstance();
const rates = await cryptoCompare.getExchangeRates(['BTC', 'ETH']);
console.log('Exchange Rates:', rates);
}
fetchExchangeRates();new CryptoCompare():
CryptoCompare
Defined in: src/services/providers/cryptoCompare.ts:69
Private constructor to enforce the singleton pattern.
Initializes the AxiosWrapper and the LRU cache.
CryptoCompare
If an instance already exists.
getExchangeRates(
ids,vsCurrency?):Promise<CryptoComparePrice>
Defined in: src/services/providers/cryptoCompare.ts:163
Retrieves exchange rates for an array of cryptocurrency symbols.
Handles splitting the symbols into batches to comply with API limitations.
string[]
An array of cryptocurrency symbols (e.g., ['BTC', 'ETH']).
string = 'BTC'
The target currency symbol (default is 'BTC').
Promise<CryptoComparePrice>
An object mapping cryptocurrency symbols to their exchange rates.
const cryptoCompare = CryptoCompare.getInstance();
const rates = await cryptoCompare.getExchangeRates(['BTC', 'ETH'], 'USD');
console.log('Exchange Rates:', rates);getMarketData(
ids,vsCurrency?):Promise<CryptoCompareMarkets>
Defined in: src/services/providers/cryptoCompare.ts:226
Retrieves market data for an array of cryptocurrency symbols.
Handles splitting the symbols into batches to comply with API limitations.
string[]
An array of cryptocurrency symbols (e.g., ['BTC', 'ETH']).
string = 'BTC'
The target currency symbol (default is 'BTC').
Promise<CryptoCompareMarkets>
An object containing detailed market data.
const cryptoCompare = CryptoCompare.getInstance();
const marketData = await cryptoCompare.getMarketData(['BTC', 'ETH'], 'USD');
console.log('Market Data:', marketData);
staticgetInstance():CryptoCompare
Defined in: src/services/providers/cryptoCompare.ts:92
Returns the singleton instance of the CryptoCompare class.
CryptoCompare
The singleton instance of CryptoCompare.
const cryptoCompare = CryptoCompare.getInstance();