Coingecko

Coingecko API is built for simple price queries using unique coin IDs

Coingecko API is a market-data interface that lets applications request one or more cryptocurrency prices through service-defined coin IDs. For the Simple Price endpoint, the caller supplies an ids list and one or more vs_currencies; the JSON response is keyed by those same IDs. Using bitcoin, ethereum, and solana avoids the ambiguity of tickers such as BTC, ETH, or duplicated symbols in automated joins.

Updated: 29 Jul 2026

Ticker collisions break unattended price joins

Ticker collisions are the central identity failure in automated price retrieval. A CoinGecko coin ID identifies one listed asset, while a symbol can correspond to several listings.

That distinction matters before any price enters a database. Bitcoin uses bitcoin, Ethereum uses ethereum, Solana uses solana, and USDC uses usd-coin. These strings are lookup keys, not blockchain tickers or contract addresses. Store each ID beside the internal asset record, then join responses through that field. A symbol remains useful for display, search, and exchange-pair labels, but it should not become the primary key.

Symbol lookup has extra ambiguity controls. The include_tokens=all setting applies only to symbols and accepts no more than 50 symbols in one request. Its default top behavior selects a leading match by market capitalization or volume. An ID lookup bypasses that ranking decision and resolves the asset specified by the mapping.


Batching coin IDs changes credit consumption

A batched ID request reduces call consumption because comma-separated IDs travel in one HTTP GET. Coingecko API counts one request as one call, so three IDs in one request use one call while three separate requests use three.

Successful responses with HTTP status 200 deduct one credit from a paid plan's monthly allowance. Unsuccessful 4xx and 5xx responses do not deduct that monthly credit, yet every request still enters the minute-rate calculation. Repeating a malformed request therefore consumes throughput even when it returns no price data. A 429 response calls for delayed retries with exponential backoff, not an immediate loop.

Batching does not make every payload equally efficient. Send assets sharing the same quote currencies and optional fields together. Separate requests only when schedules, freshness policies, access paths, or practical request-length limits differ. This structure also keeps a dashboard refresh from issuing one network call per row.

The coins list supplies canonical mappings

The /coins/list catalog supplies the canonical ID, symbol, and name mapping used by ID-based endpoints. Its default response covers active listings and returns the complete catalog without pagination.

Each basic record carries three core fields: id, symbol, and name. The include_platform option defaults to false; setting it to true adds platform identifiers and known token contract addresses. The status filter has two documented values, active and inactive. On the Pro API, this catalog has a five-minute cache or update frequency.

Fetch the catalog in a separate mapping job rather than before every price request. Validate that each internal asset resolves to exactly one ID, preserve the previous mapping snapshot, and publish the new registry atomically. Price polling then reads a small, approved set of IDs instead of scanning names repeatedly.


Two parameters define a Simple Price request

A Coingecko API Simple Price request needs an asset selector and a quote-currency selector. The usual ID-first form sends ids and vs_currencies to GET /simple/price.

A request containing three IDs and two quote currencies returns up to three top-level asset objects, each with fields for both currencies when data exists. For example, ids=bitcoin,ethereum,solana pairs cleanly with vs_currencies=usd,eur. The response remains smaller than a full market-data record because all four enrichment flags are optional.

ID priority settles mixed lookup parameters

Mixed lookup parameters follow a three-level priority: IDs outrank names, and names outrank symbols. The Simple Price endpoint therefore uses ids when a request also supplies names or symbols.

This precedence prevents conflicting selectors from merging into an unpredictable asset set, but it can hide a client bug. Build one lookup mode per request and reject mixed selectors before transmission. Names containing spaces require URL encoding, while wildcard searches are unsupported for IDs, names, and symbols. Exact matching keeps the mapping explicit.

Symbol mode also changes the response decision. With include_tokens=all, the caller receives every matching token within the 50-symbol request ceiling. ID mode needs no equivalent switch because each stored ID already names the intended listing.

ID-keyed JSON makes response joins deterministic

The Simple Price response is a JSON object keyed by the requested coin IDs. Each returned ID contains quote-currency fields and any optional metrics enabled by the request.

For a USD lookup, bitcoin contains usd. Enabling market cap, 24-hour volume, and 24-hour change adds fields such as usd_market_cap, usd_24h_vol, and usd_24h_change. The last_updated_at field is a Unix timestamp expressed in seconds. This flat naming scheme makes each value traceable to one asset ID and one quote currency.

Join by the object key rather than the response's textual order. Validate every expected key before updating balances, and represent a missing field as unavailable rather than zero. Zero is a valid numeric value in many data systems; absence describes a different state and should remain distinguishable.

Precision controls digits while timestamps control freshness

The precision parameter controls returned decimal places, whereas last_updated_at describes data age. Neither setting changes which CoinGecko coin ID the request resolves.

The precision parameter accepts full or an integer from 0 through 18 decimal places, producing 20 documented settings. Choose precision for the consuming interface, then retain a higher-precision representation inside calculations when the application needs it. Decimal formatting does not make an older observation fresh.

The Pro Simple Price cache updates every 20 seconds. Polling every five seconds therefore produces four requests within one cache interval without guaranteeing four distinct observations. Enable include_last_updated_at, compare that timestamp with the application clock, and attach the observation time to each stored price. The 24-hour change field also returns null when the price is stale, providing another explicit quality signal.

Contract addresses add chain-specific identity

A contract-address lookup identifies a token deployment on one blockchain, while a CoinGecko coin ID identifies the cataloged asset. Cross-chain tokens therefore need both an asset-level mapping and platform-specific address records.

USDC illustrates the relationship. Its CoinGecko ID remains usd-coin, while deployments on Ethereum, Solana, Base, Polygon PoS, and Arbitrum One use different address formats or values. Ethereum tokens follow the ERC-20 interface; Solana tokens are represented by mint addresses under the SPL Token model. A bare contract string lacks sufficient context because its meaning belongs to a particular asset platform.

Use /coins/list with include_platform=true to build the address map. For address-native price requests, /simple/token_price/{id} takes an asset-platform ID in the path and contract addresses in the query. Native Bitcoin has no ERC-20 contract address, so its regular bitcoin coin ID remains the appropriate selector.

A persistent registry keeps mappings recoverable

A persistent ID registry separates identity recovery from live price collection. JSON tracked by Git, PostgreSQL, SQLite, and Redis can store the same provider ID, though their recovery models differ materially, which is discussed in Coingecko step by step.

Registry form Identity constraint Refresh behavior Backup or recovery standard
Versioned JSON with Git One provider ID per validated record Atomic file replacement after catalog validation Commit history or tagged-release restore
PostgreSQL table Unique provider and coin-ID constraint Transactional upsert Base backup plus WAL point-in-time recovery
SQLite database Unique index on the coin-ID column Single database transaction Online Backup API or consistent file snapshot
Redis cache Namespaced key for provider and coin ID Rebuilt or overwritten from the registry AOF or RDB restore, otherwise catalog rebuild

Versioned JSON works for a small, reviewed asset universe. PostgreSQL gives several services one constrained source of truth, while SQLite fits a local process without a separate database server. Redis serves fast lookups but belongs downstream of a recoverable registry. Keep display names and symbols as mutable attributes; the internal row should join through the approved CoinGecko ID.

Record the catalog retrieval time and mapping revision. If an asset is added, renamed, or removed from the active catalog, the revision shows which identity set produced earlier valuations. That history is more useful than copying the latest symbol over every prior record.


The markets endpoint replaces Simple Price for richer rows

The /coins/markets endpoint is the appropriate ID-based request when each row needs supply, rank, daily range, images, or multi-period change fields. Simple Price remains leaner for current values and four optional metric families.

Market rows default to 100 results per page, accept values from 1 through 250, and begin on page 1. The sparkline flag defaults to false; when enabled, it adds seven-day sparkline data. Percentage-change windows support seven documented intervals: 1 hour, 24 hours, 7 days, 14 days, 30 days, 200 days, and 1 year. The Pro cache or update frequency is 30 seconds.

Use the same canonical IDs in either endpoint. This preserves one identity registry while allowing separate response schemas. A compact price widget reads Simple Price, whereas a ranked research table reads market rows without rebuilding its asset mapping around symbols.


ID-first pricing suits repeatable valuation workflows

ID-first price retrieval suits dashboards, accounting snapshots, portfolio summaries, alerting systems, and scheduled data pipelines. These workflows benefit from a stable join between an internal asset record and a provider-specific lookup key.

Python's Requests library, JavaScript's fetch, an n8n HTTP Request node, or a Google Sheets script can send the same ID-based query. A common architecture separates one slower catalog-refresh process from a faster price poller. PostgreSQL stores the reviewed mappings, Redis caches lookups, and downstream jobs write prices with their quote currency and update timestamp.

Coingecko API ID-first pricing is less suitable as a substitute for an exchange order book. Its value represents aggregated market data rather than an executable bid or ask at one venue. Use it for consistent reference valuations across Bitcoin, Ethereum, Solana, and token portfolios; use venue-specific market data when execution price and available depth determine the decision.

Coingecko API: quick answers

Can one request return prices in both USD and EUR?

Yes. The vs_currencies parameter accepts a comma-separated set of supported quote currencies, so one ID batch returns USD and EUR fields beneath every available coin key. The currency list changes the response width, not the identity mapping. Read the supported-currencies endpoint at runtime instead of hard-coding assumptions about which fiat or crypto units are accepted.

Does ID-based pricing require an official software development kit?

No. Simple Price is an ordinary HTTPS GET endpoint that returns JSON, so standard clients work without a dedicated software development kit. JavaScript fetch, Python Requests, cURL, and n8n can send the same parameters. A wrapper library remains useful for retries, validation, and typed responses, but it does not change the CoinGecko ID rules.

How should a client handle an ID missing from the response?

A client should mark the requested asset as unavailable and leave its previous observation distinguishable from a new value. Never convert a missing object or null field into zero. Compare the returned top-level keys with the requested ID set, log the absent ID, and refresh the local catalog mapping before retrying. This preserves the difference between missing data and a numeric price.

What happens after an HTTP 429 response?

An HTTP 429 response means the request rate exceeded the applicable limit. Pause requests, apply exponential backoff, and honor a retry delay when the response supplies one. Immediate repeated calls extend the problem because every request, including unsuccessful requests, enters the minute-rate calculation. Batching IDs and aligning polling with the endpoint's cache window reduce unnecessary retry pressure.

Will adding more quote currencies change the coin ID?

No. A CoinGecko coin ID identifies the asset independently of its quote currencies. Adding USD, EUR, or BTC changes the fields nested beneath that ID, while the top-level key stays the same. Store the quote currency beside every recorded value because the ID alone identifies the asset, not the denomination or observation time.

Can Simple Price replace an exchange order-book quote?

No. Simple Price returns aggregated market data rather than an executable bid, ask, or depth level from one exchange. It fits dashboards, reference valuations, and portfolio calculations. An execution workflow needs venue-specific order-book data because fill price depends on the selected market, available quantity, order type, fees, and the book's state when the order reaches it.

How can automated tests avoid failures when crypto prices move?

Automated tests should mock a small JSON response and assert structure instead of asserting a live price. Test that requested IDs become top-level keys, quote fields remain numeric, optional timestamps parse correctly, and missing values stay distinct from zero. Keep a separate integration test for network access, but validate its schema and HTTP status rather than expecting a fixed Bitcoin or Ethereum value.

Are CoinGecko coin IDs guaranteed never to change?

Treat CoinGecko coin IDs as canonical service identifiers, not immutable blockchain constants. Store them in a versioned registry, refresh the catalog on a controlled schedule, and review mapping changes before publication. Keeping symbols, names, chain identifiers, and contract addresses beside each ID makes reconciliation possible when a listing changes while preserving the mapping used for earlier price records.