- More Supported Coins – Coinbase Pro only provided quotes for the coins tradable on Coinbase, which is vast, but still limited. CoinMarketCap supports many more.
- More efficient API – Perhaps this doesn’t matter too much since I am using Airtable resources at no additional cost to me, but I still liked the idea of being able to make 1 fetch() call for all coins rather than 1 per coin. Should fetch() limits from Airtable come some day or API rate limits hit with more coins being used, I was able to simplify everything with 1 fetch() for all coins.
- More Information – CoinMarketCap provides a lot more information in a quote. I am using the Quotes Latest call and you can see all the info provided in their docs.
The Quotes Latest call provides a lot of good data. This is from their docs and provides a good overview of what’s available.
We will use the same Base table from the previous post, but with a few additions.
- Price % Change (24h) is a percent field with 2 decimal point precision that allows negative numbers.
- Price % Change (7d) is a percent field with 2 decimal point precision that allows negative numbers.
- Rank is an integer field. This will hold CoinMarketCap’s rank for the coin/token.
- The Market field does not matter for this integration. I used it for the Coinbase Pro example. If you prefer CoinMarketCap, you don’t really need it.
Here’s a look at the Coins table.
To use the CoinMarketCap API, you need to get an API key. There is a free plan and the free plan includes calls to the Quotes Latest method, so there is no cost to getting an API key. Getting the key also gives you access to a nice API dashboard to track your usage and errors.
I have this setup in an Automation scheduled once per day that runs a script. In my previous post, I went into more detail on setting up and debugging the automation. If you are not familiar with setting up an Automation, check out that post.
The code is below. You should be able to just plop this right into your automation. Look for the text that says “YOUR_KEY_HERE”. Replace that text with your API key. I have examples of pulling data from the first level (rank) as well as information from the quote (price, % change)
The code has now run and has populated the Price, % change over 24 hours, % change over 7 days, the rank, and a timestamp for when it received the data.
For my personal use, I have moved over to this API and run it every 3 hours.