CryptoCompare API Integration
CryptoCompare is one of the oldest crypto market aggregators with data since 2010. Unlike CoinGecko and CoinMarketCap, CryptoCompare's strength is historical OHLCV data and exchange data: prices from specific trading pairs on specific exchanges, not averaged aggregates. This makes it essential for trading applications, strategy backtesting, and analytical dashboards.
What the API Provides
Real-time prices—/data/price, /data/pricemulti, /data/pricemultifull. The latter returns expanded data: 24h change, volume, market cap, last exchange and price.
Historical OHLCV—this is the main advantage:
-
/data/v2/histominute—minute candles (maximum 2000 points per request) -
/data/v2/histohour—hourly -
/data/v2/histoday—daily (data from 2010 for major pairs)
The toTs parameter allows pagination into the past—to load full history need several requests with recursive shift.
WebSocket—/streaming/ endpoint for real-time updates. Supports subscriptions to trading pairs from specific exchanges.
Typical Integration Tasks
Getting Multi-Currency Prices
const response = await fetch(
`https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,SOL&tsyms=USD,EUR&api_key=${API_KEY}`
)
const prices = await response.json()
// { BTC: { USD: 67000, EUR: 62000 }, ETH: { ... } }
Rate limit on free tier—100 calls/month for some endpoints, 250k calls/month for basic. Cache results—prices change every few seconds, requesting them on every user action is excessive.
Loading Historical Data
async function fetchFullHistory(fsym: string, tsym: string): Promise<OHLCV[]> {
const results: OHLCV[] = []
let toTs = Math.floor(Date.now() / 1000)
while (true) {
const res = await fetch(
`https://min-api.cryptocompare.com/data/v2/histoday` +
`?fsym=${fsym}&tsym=${tsym}&limit=2000&toTs=${toTs}&api_key=${API_KEY}`
)
const data = await res.json()
const candles = data.Data.Data
if (candles.length === 0 || candles[0].time === 0) break
results.unshift(...candles)
toTs = candles[0].time - 1
await sleep(300) // rate limit
}
return results
}
WebSocket for Real-time
const ws = new WebSocket('wss://streamer.cryptocompare.com/v2?api_key=' + API_KEY)
ws.onopen = () => {
ws.send(JSON.stringify({
action: 'SubAdd',
subs: ['5~CCCAGG~BTC~USD', '5~CCCAGG~ETH~USD']
// format: type~market~fsym~tsym
// type 5 = aggregated price
}))
}
ws.onmessage = (event) => {
const msg = JSON.parse(event.data)
if (msg.TYPE === '5') {
// price update
console.log(msg.FROMSYMBOL, msg.PRICE)
}
}
CCCAGG—aggregated price across all exchanges. For price from specific exchange: 5~Binance~BTC~USDT.
Limitations and Gotchas
Data is not real-time in strict sense—CryptoCompare aggregated price lags exchange data by 1–5 seconds. Not suitable for HFT or arbitrage. For dashboards and analytics—sufficient.
Uneven coverage—for top-100 coins data is good, for illiquid altcoins—may be gaps in history or stale prices.
API key in client code—common mistake. Key should be on server, client goes to your proxy endpoint. Otherwise key leaks, you exceed limits, get a bill.
Plan rate limits—free tier is limited. For production: Starter ($29/month) or higher. Before choosing a plan—calculate your app's real RPS.
What Gets Done in 2–3 Days
Server proxy for API requests with caching (Redis or in-memory), integration of endpoints: current prices, OHLCV history, WebSocket stream, TypeScript/Python SDK wrapper for your stack, basic UI component or ready data for your frontend.







