npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@molecule/api-crypto-prices-coingecko

v1.0.2

Published

CoinGecko crypto-prices provider for molecule.dev

Downloads

341

Readme

@molecule/api-crypto-prices-coingecko

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.ts JSDoc, 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.

Quick Start

import { setProvider } from '@molecule/api-crypto-prices'
import { provider } from '@molecule/api-crypto-prices-coingecko'

setProvider(provider)

Type

provider

Installation

npm install @molecule/api-crypto-prices-coingecko @molecule/api-crypto-prices

API

Interfaces

CoinGeckoCryptoPricesConfig

Configuration 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
}

Classes

CoinGeckoRateLimitedError

Error 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.

Functions

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.

Constants

provider

The 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_LIMITED

Stable 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'

Core Interface

Implements @molecule/api-crypto-prices interface.

Bond Wiring

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)
}

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-crypto-prices ^1.0.1

Environment Variables

  • COINGECKO_API_KEY (optional) — CoinGecko Pro API key
    • Setup: Optional. Leave unset to use the free keyless public endpoint (conservative rate limits). Set a Pro key to switch to pro-api.coingecko.com with higher limits.
    • Get it here: https://www.coingecko.com/en/api/pricing
    • Example: CG-...

Runtime Dependencies

  • @molecule/api-crypto-prices

E2E Tests

Integration 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:

  • [ ] A known coin's spot price renders in the UI: 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 "—".
  • [ ] The market list shows DISTINCT prices: 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.
  • [ ] If a chart/detail screen is exposed, 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.
  • [ ] Switching the quote currency (USD→EUR) re-fetches with the new vsCurrency and the displayed values CHANGE, shown with the right symbol and precision ($/€, not a raw float).
  • [ ] Prices refresh: a later 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.
  • [ ] Edge/error: an unknown coin id or symbol surfaces a clear "not found" in the UI, and a provider/rate-limit failure degrades gracefully (stale-but- shown or an empty state) — never a crash, blank, or NaN.
  • [ ] The provider API key (if the bonded provider needs one) stays server-side: the browser calls the app's own endpoint, never the upstream API directly, and that endpoint isn't an open proxy for arbitrary coin/currency params.