Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a list of the 300 first coins of coingecko API by marketcap?

If I make a request to get the full list of coingecko coins using with

https://api.coingecko.com/api/v3/coins/list

and get the ids of each coins taking the 'id' entry.

Then I can loop on all coins id with a

https://api.coingecko.com/api/v3/simple/price?ids=<coin>&vs_currencies=usd

(in which <coin> should be replaced by the id coming from the full list) (e.g. https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd to get bitcoin price), and then reorder it by marketcap.

This works but the problem is that there are many requests and this is taking ages (a few hours at least).

It there a possibility to immediately get the id of the first 300 coins by marketcap?

like image 428
saturn Avatar asked Jul 24 '20 14:07

saturn


People also ask

How do I fetch CoinGecko API?

Go to https://www.coingecko.com/en/api and scroll about halfway down. There, you'll see the types of requests you can make. Since my application needs to bring in some data from CoinGecko, I want to make a GET request. That's exactly what CoinGecko enables.

How do I get my list on CoinGecko?

To be listed on CoinGecko, a cryptocurrency must first be tradable on a cryptocurrency exchange tracked by CoinGecko. For the full list of exchanges tracked by CoinGecko, visit our Exchange page. There is NO LISTING FEE for coins/tokens listings on CoinGecko.

Is CoinGecko listing free?

We plan to continue providing excellent service to the crypto community with our completely free API, free listing for projects, exchanges and more!


Video Answer


1 Answers

There is Coingecco API request markets that returns coin price, market cap and market cap rank among other info. You can sort it by market cap rank and just take 300 first elements of JSON array.

https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc

Response looks like:

[
  {
    "id": "bitcoin",
    "symbol": "btc",
    "name": "Bitcoin",
    "image": "https://assets.coingecko.com/coins/images/1/large/bitcoin.png?1547033579",
    "current_price": 9664.88,
    "market_cap": 178353923560,
    "market_cap_rank": 1,
    ...
    "last_updated": "2020-07-26T05:05:03.478Z"
  },
  {
    "id": "ethereum",
    "symbol": "eth",
    "name": "Ethereum",
    "image": "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880",
    "current_price": 302.53,
    "market_cap": 33895800150,
    "market_cap_rank": 2,
...
    },

UPD: To get exactly 300 results use the following request:

https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=3
like image 104
Yuri Ginsburg Avatar answered Sep 21 '22 12:09

Yuri Ginsburg