CoinGecko API for USDC: Price Endpoints and Examples
To get USDC's price from the CoinGecko API, call /simple/price with ids=usd-coin and vs_currencies=usd. To query by contract on Base, call /simple/token_price/base with the native USDC contract address. Demo keys use the api.coingecko.com root and the x-cg-demo-api-key header; Pro keys use pro-api.coingecko.com and x-cg-pro-api-key.
Finding the coin ID
CoinGecko identifies assets by coin IDs. USDC's ID is usd-coin. The coins list endpoint returns all IDs, and each coin's detail endpoint includes its contract addresses on supported platforms, which helps confirm you are querying the right asset.
Simple price by ID
The simple price endpoint returns current prices for one or more coin IDs in one or more currencies. A request such as GET /simple/price?ids=usd-coin&vs_currencies=usd returns USDC's price in US dollars. Optional parameters add market cap, 24-hour volume, 24-hour change, and last updated time.
Token price by contract on Base
To query by contract address, use GET /simple/token_price/{id}, where id is the asset platform. For Base, the platform ID is base. Pass the native USDC contract address in contract_addresses and set vs_currencies=usd. This is useful when your system tracks tokens by address rather than coin ID.
Authentication with a Demo key
Demo plan requests use the root https://api.coingecko.com/api/v3/ and pass the key in the x-cg-demo-api-key header, or as the x_cg_demo_api_key query parameter. Headers are preferable because they keep keys out of logs and URLs.
Authentication with a Pro key
Paid plans use the root https://pro-api.coingecko.com/api/v3/ with the x-cg-pro-api-key header or the x_cg_pro_api_key query parameter. Mixing roots and headers is a common cause of authentication errors.
Rate limits
Each plan has rate limits and monthly call allowances. Check CoinGecko's current plan details, handle HTTP 429 responses with backoff, and avoid polling more often than your use case needs.
Caching
USDC is designed to hold one dollar, so its price rarely changes meaningfully minute to minute. Cache results for a reasonable interval to save calls. Refresh more often only if you monitor for depeg events.
Monitoring for depegs
If your system relies on USDC holding its value, compare its price against a threshold and alert when it deviates. Combine CoinGecko data with other sources for critical decisions, since any single data provider can lag or err.
Historical data
Market chart and history endpoints return past prices, useful for reporting, accounting, or analysing stability over time. Check plan limits on historical ranges.
Using prices in payment systems
Payment systems that price services in USDC usually do not need live USDC prices, since one USDC is treated as one dollar. Price feeds matter more when converting other tokens to USDC values or reporting in other currencies.
Using prices in agents
Agents that budget in dollars while paying in USDC can treat USDC at par for normal operation and use a price check as a safety circuit: if USDC trades far from one dollar, pause spending and alert a human.
Example request flow
A service sends a GET request to the simple price endpoint with the appropriate key header, parses the JSON response keyed by coin ID and currency, caches the value with a timestamp, and returns the cached value until it expires. Errors fall back to the last known value with a warning.
Alternatives
Other market data providers, exchange APIs, and onchain oracles also provide USDC prices. Onchain oracles suit smart contracts that need prices onchain; APIs suit offchain services and dashboards.
Comparing several stablecoins
To monitor several stablecoins together, pass multiple coin IDs in a single simple price request, separated by commas, and request prices in the currencies you report in. One request per interval is cheaper than separate requests per token and keeps timestamps consistent across assets.
Handling errors
Handle network errors, rate limit responses, and malformed data gracefully. Retry with exponential backoff, cap retries, and fall back to cached values with a staleness flag. For critical decisions, require fresh data or a second source before acting.
Security of API keys
Store CoinGecko keys in a secrets manager or environment configuration, not in client-side code or public repositories. Use headers rather than query parameters so keys do not appear in logs, and rotate keys if they may have been exposed.
Using the data in dashboards
Dashboards showing balances in agent wallets can multiply USDC amounts by the current price for display, though most treat USDC at one dollar. Showing the last updated time alongside prices helps users judge freshness.
Testing your integration
Use the Demo plan to prototype, write tests that mock API responses including errors and rate limits, and verify that your code reads the correct keys from the response. Move to a paid plan only when call volume or data needs require it.
Frequently asked questions
- What is USDC's ID in the CoinGecko API?
- USDC's CoinGecko coin ID is usd-coin. Use it with the simple price endpoint, for example /simple/price?ids=usd-coin&vs_currencies=usd, or with coin detail and market chart endpoints. The coin detail response also lists USDC's contract addresses on supported platforms such as Base.
- How do I get the USDC price on Base from CoinGecko?
- Call /simple/token_price/base with contract_addresses set to the native USDC contract on Base and vs_currencies=usd. The platform ID for Base is base. This returns the price for that specific contract, which helps avoid confusion with bridged versions such as USDbC.
- Which header does the CoinGecko API key use?
- A free Demo key now needs registering for reliable access, since calling without one falls back to an informal public tier with much tighter limits. Demo keys use the x-cg-demo-api-key header with the api.coingecko.com root. Pro keys use the x-cg-pro-api-key header with the pro-api.coingecko.com root. Both also accept a query parameter version, but headers keep keys out of URLs and logs.
