← All @molecule/* packages · App templates
@molecule/api-crypto-prices-coingeckoProvider bond · crypto-prices · API (Node) · v1.0.1 · Apache-2.0
CoinGecko crypto-prices provider — keyless free tier with optional Pro API key for higher rate limits.
npm install @molecule/api-crypto-prices-coingeckonpm · Source on GitHub · Implements @molecule/api-crypto-prices
@molecule/api-crypto-prices-coingecko is a provider bond on the API (Node) side: it implements the crypto-prices core interface (@molecule/api-crypto-prices) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
import { setProvider } from '@molecule/api-crypto-prices'
import { provider } from '@molecule/api-crypto-prices-coingecko'
setProvider(provider)Works with: @molecule/api-crypto-prices
Secrets: COINGECKO_API_KEY (optional)
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
CoinGecko crypto-prices provider for molecule.dev.
Implements the CryptoPricesProvider interface against the CoinGecko v3
API. The public endpoint (https://api.coingecko.com/api/v3) is keyless
and free for personal / non-commercial use, with conservative
rate-limits. Setting the COINGECKO_API_KEY environment variable
switches to the Pro endpoint (https://pro-api.coingecko.com/api/v3)
and authenticates with the x-cg-pro-api-key header.
import { setProvider } from '@molecule/api-crypto-prices'
import { provider } from '@molecule/api-crypto-prices-coingecko'
setProvider(provider)
provider
npm install @molecule/api-crypto-prices-coingecko @molecule/api-crypto-prices
CoinGeckoCryptoPricesConfigConfiguration options for the CoinGecko crypto-prices provider.
The CoinGecko public API
(https://api.coingecko.com/api/v3) is keyless and free for personal /
non-commercial use, so all fields are optional. Setting {@link apiKey}
switches the provider to the CoinGecko Pro endpoint
(https://pro-api.coingecko.com/api/v3) and authenticates with the
x-cg-pro-api-key header.
interface CoinGeckoCryptoPricesConfig {
/**
* Base URL override. Defaults to `'https://api.coingecko.com/api/v3'` when
* {@link apiKey} is omitted, or `'https://pro-api.coingecko.com/api/v3'`
* when {@link apiKey} is set.
*/
baseUrl?: string
/**
* CoinGecko Pro API key. When set, the provider uses the Pro host and
* sends the `x-cg-pro-api-key` header. The free public endpoint requires
* no key.
*/
apiKey?: string
/**
* Request timeout in milliseconds. Defaults to `10000`.
*/
timeout?: number
}
CoinGeckoRateLimitedErrorError thrown by the CoinGecko provider when the upstream API rejects a request with HTTP 429 (Too Many Requests).
The error never includes the configured API key (or any other secret) in its message or properties.
createProvider(config)Creates a CoinGecko crypto-prices provider.
function createProvider(config?: CoinGeckoCryptoPricesConfig): CryptoPricesProvider
config — Provider configuration. All fields are optional.Returns: A {@link CryptoPricesProvider} backed by the CoinGecko v3 API.
providerThe provider implementation, lazily initialized on first use.
Reads COINGECKO_API_KEY and COINGECKO_BASE_URL from environment
variables. When COINGECKO_API_KEY is set the provider routes traffic
to the Pro endpoint and authenticates with the x-cg-pro-api-key header;
the public free tier requires no key.
const provider: CryptoPricesProvider
RATE_LIMITEDStable error code emitted by the CoinGecko provider when the upstream API returns HTTP 429 (Too Many Requests).
Catch on this constant rather than parsing error messages — the message text is for humans only.
const RATE_LIMITED: 'RATE_LIMITED'
Implements @molecule/api-crypto-prices interface.
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-crypto-prices'
import { provider } from '@molecule/api-crypto-prices-coingecko'
export function setupCryptoPricesCoingecko(): void {
setProvider(provider)
}
Peer dependencies:
@molecule/api-crypto-prices ^1.0.1COINGECKO_API_KEY (optional) — CoinGecko Pro API key
CG-...@molecule/api-crypto-pricesIntegration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual screens/flows, and check every box off one by one. A box you can't check is an integration bug to fix — not a skip:
getPrice(id, 'usd') (id
from listCoins()/listSupportedSymbols(), never a hardcoded provider id)
returns a CoinPriceQuote with a PLAUSIBLE price (BTC is thousands of
USD, not 0/null/NaN) and it shows on screen, not "—".listCoins() renders multiple
CoinMarketRows and each coin's price is its own value (BTC ≠ ETH, not a
repeated copy), with symbol/name matching the row.getHistorical(id, days) returns a
series of CoinPricePoint (ts, price) samples in chronological order that
render as a line/spark chart — not a single point or an empty box.vsCurrency and the displayed values CHANGE, shown with the right symbol
and precision ($/€, not a raw float).getPrice/listCoins can return a different
price/change24h and the UI updates (or shows an "as of" time from
asOf) — it isn't frozen at first paint.