
π Documentation & Examples
Everything you need to integrate with CoinGecko
π Quick Start Examples
// CoinGecko API Example
const response = await fetch('http://www.coingecko.com/api', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);Introducing the Coingecko API
Are you a cryptocurrency enthusiast who loves to stay updated with the latest market trends? Or a developer who is constantly looking for new ways to integrate cryptocurrency data into your project? Then you're in the right place!
Coingecko offers an incredible API that provides comprehensive data on cryptocurrencies. In this post, we will cover the details of this API and provide some code examples on how to use it in your JavaScript application.
How to Get a CoinGecko API Key
CoinGecko's public API now runs on a free Demo plan that uses an API key:
- Sign up at the CoinGecko developer dashboard (no credit card needed).
- Create a Demo API key.
- Send it in the
x-cg-demo-api-keyrequest header (or as thex_cg_demo_api_keyquery param).
The Demo plan allows roughly 10,000 calls per month. The base URL stays https://api.coingecko.com/api/v3:
curl "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd" \
-H "x-cg-demo-api-key: YOUR_API_KEY"
A fully keyless public API still exists for quick prototyping, but it's heavily rate-limited and CoinGecko now recommends the free Demo key for anything real. Paid Pro plans use a different host (https://pro-api.coingecko.com) with the x-cg-pro-api-key header. For the free tier, grab a Demo key from the dashboard and attach the header.
Making Requests with the Coingecko API in JavaScript
Now that we have our API key and know the endpoint we want to hit, let's dive into some code examples on how to use the Coingecko API in JavaScript.
Example 1: List of cryptocurrencies
fetch('https://api.coingecko.com/api/v3/coins/list')
.then(response => response.json())
.then(data => console.log(data));
This code makes a request to the Coingecko API's list of cryptocurrencies endpoint and logs the response data in the console.
Example 2: Cryptocurrency price
fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd')
.then(response => response.json())
.then(data => console.log(data));
This code makes a request to the Coingecko API's cryptocurrency price endpoint for Bitcoin and logs the response data in the console.
Example 3: Cryptocurrency market chart
fetch('https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=30')
.then(response => response.json())
.then(data => console.log(data));
This code makes a request to the Coingecko API's cryptocurrency market chart endpoint for Bitcoin over the last 30 days, and logs the response data in the console.
Conclusion
The Coingecko API provides developers with a powerful tool for accessing cryptocurrency data. With its comprehensive set of endpoints and easy-to-use format, integrating cryptocurrency data into your project has never been easier. Happy coding!









