DEV Community

Pull Live Crypto Market Data Without a Rate Limited Key

The Keyless Endpoint

CoinGecko serves a public market endpoint that returns a tidy array of coins:

GET https://api.coingecko.com/api/v3/coins/markets
  ?vs_currency=usd
  &order=market_cap_desc
  &per_page=250
  &page=1
  &price_change_percentage=1h,24h,7d,30d

No key, no header, no login. Each coin comes back with the fields you actually want:

  • current_price, market_cap, market_cap_rank
  • total_volume, fully_diluted_valuation
  • circulating_supply, total_supply, max_supply
  • ath, ath_change_percentage, atl
  • price_change_percentage_24h_in_currency, _7d_, _30d_ and more

Page in Big Chunks

The mistake that gets people rate limited is hammering the endpoint one coin at a time. Do the opposite. per_page goes up to 250, so a thousand coins is four requests, not a thousand. Walk the pages until you hit your cap or an empty page:

let page = 1, out = [];
while (out.length < cap) {
  const res = await fetch(
    `${base}/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=250&page=${page}&price_change_percentage=1h,24h,7d,30d`
  );
  if (res.status === 429) {
    await sleep(15000);
    continue;
  }
  const data = await res.json();
  if (!data.length) break;
  out.push(...data);
  if (data.length < 250) break;
  page += 1;
}

The only thing to handle is the occasional 429. A short backoff and retry is enough, because with per_page=250 you make so few calls that you rarely hit it.

Watchlist Mode

If you only care about a few coins, pass ids=bitcoin,ethereum,solana and you get just those in a single call. Same shape, no filtering in your own code.

I Packaged It

I turned this into a small Actor on Apify so it is callable from code without writing the paging by hand. You set a quote currency, a sort and a cap, or a list of coin ids for a watchlist, and it returns one row per coin with price, market cap and rank, volume, supply, all time high and low, and 1h to 30d change. It joins a growing set of keyless finance and market scrapers I have been shipping. The first rows of every run are free so you can check the output first.

The pattern generalizes: before you reach for a paid data plan, check whether the site you already trust serves the same numbers over a public endpoint. For crypto, it does.

Comments

No comments yet. Start the discussion.