DEV Community

Donny Nguyen
Donny Nguyen

Posted on

CoinGecko Crypto Prices API — Free to Use

Getting Crypto Prices with CoinGecko API

Building a crypto app? You need reliable price data. The CoinGecko Crypto Prices API gives you real-time cryptocurrency market data without the complexity of building your own data pipeline.

What It Does

This REST API serves current cryptocurrency prices and market information. Query any coin and get instant pricing data perfect for dashboards, trading alerts, or portfolio trackers. No authentication headaches—just straightforward endpoints that return JSON.

Making Your First Request

Here's a practical example using fetch() to get Bitcoin's current price:

async function getCryptoPrice(coin) {
  const url = `https://coingecko-crypto-prices-api-production.up.railway.app/api/price?coin=${coin}`;

  try {
    const response = await fetch(url);
    const data = await response.json();

    console.log(`${coin} Price:`, data);
    return data;
  } catch (error) {
    console.error('API Error:', error);
  }
}

// Usage
getCryptoPrice('bitcoin');
getCryptoPrice('ethereum');
getCryptoPrice('cardano');
Enter fullscreen mode Exit fullscreen mode

The endpoint returns market data including current price, market cap, 24h volume, and price changes:

{
  "price": 42350.50,
  "market_cap": 825000000000,
  "volume_24h": 32000000000,
  "price_change_24h": 2.5,
  "last_updated": "2024-01-15T14:30:00Z"
}
Enter fullscreen mode Exit fullscreen mode

Real-World Use Case

Building a portfolio tracker? Fetch multiple coins and calculate totals:

async function getPortfolioValue(holdings) {
  let totalValue = 0;

  for (const [coin, amount] of Object.entries(holdings)) {
    const data = await getCryptoPrice(coin);
    const value = data.price * amount;
    totalValue += value;
    console.log(`${coin}: $${value.toFixed(2)}`);
  }

  return totalValue;
}

// Check your portfolio
getPortfolioValue({
  'bitcoin': 0.5,
  'ethereum': 2.5,
  'solana': 10
});
Enter fullscreen mode Exit fullscreen mode

Why Use This API?

  • No rate limits (generally): Test without throttling concerns
  • Simple parameters: Just pass the coin name
  • JSON responses: Parse directly into your app
  • Fast updates: Real-time market data
  • Beginner-friendly: Perfect for learning API integration

Next Steps

Ready to integrate crypto prices into your project? Head over to RapidAPI's CoinGecko listing to subscribe and get your API key. You'll find SDKs for JavaScript, Python, Go, and more.

Start with the test endpoint above, then upgrade to production use when you're ready. Your crypto tracking app is just one API call away.

Top comments (0)