Import CoinMarketCap Data to Google Sheets
In this guide, we’ll walk through how to pull cryptocurrency data from the CoinMarketCap API directly into Google Sheets, using the API Connector add-on for Sheets. We’ll first get an API key from CoinMarketCap, and then set up a request to pull in cryptocurrency exchange rate details to your spreadsheet.
- Before You Begin
- Part 1: Get your CoinMarketCap API Key
- Part 2: Create your API Request URL
- Part 3: Pull API data into Sheets
- Part 4: More Example API URLs
- Part 5: Handle Pagination
- Appendix [PRO]: CoinMarketCap Crypto Portfolio Template
BEFORE YOU BEGIN
Click here to install the API Connector add-on from the Google Marketplace.
PART 1: GET YOUR COINMARKETCAP API KEY
- If you haven’t already, navigate to https://coinmarketcap.com/api/ and click Get Your API Key Now
- Fill out your details and click Create My Account
- A moment later you’ll receive an email. Click on the email to verify your account, and you’ll be redirected into your new CoinMarketCap dashboard. Congrats! You now have access to the CoinMarketCap API. Hover over the API Key box in the top left and copy the key to your clipboard.
PART 2: CREATE YOUR API REQUEST URL
We’ll follow the CoinMarketCap documentation to access the latest crypto quotes.
- API root: https://pro-api.coinmarketcap.com
- Endpoint: /v1/cryptocurrency/listings/latest
Putting it together, we get the full API Request URL:
PART 3: PULL COINMARKETCAP API DATA INTO GOOGLE SHEETS
We can now enter all our values into API Connector and import CoinMarketCap API data into Google Sheets.
- Open up Google Sheets and click Add-ons > API Connector > Open.
- In the Create tab, enter the API URL we just created.
- Under Headers enter two sets of key-value pairs like this:
Replace YOUR_API_KEY with the value provided above in step 3.
X-CMC_PRO_API_KEY YOUR_API_KEY Accept application/json
- Leave authentication set to None. Create a new tab and click ‘Set current’ to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see the latest market data for all active cryptocurrencies in your Google Sheet:
PART 4: MORE EXAMPLE API URLS
You can experiment with endpoints and query strings as described in the documentation to see other types of cryptocurrency data, but if you just want to jump in and get a feel for it, play around with the URLs you enter in the API URL path field. Try the following (one at a time).
- latest global cryptocurrency market metrics
- all active cryptocurrencies with latest market data, sorted by 24 hr volume
- metadata (logo, description, official website URL, social links, etc) for BTC and ETH
- latest quotes for BTC and ETH, converted to euros
Due to the structure of the underlying JSON, by default the above request will return all selected symbols in a single row. To get each coin in its own row instead, add the following JMESPath:
- Fundamental Crypto Asset Scores (FCAS) for measuring cryptocurrency project health
Note that the free version of CoinMarketCap limits the number of accessible endpoints and number of call credits. Check their pricing page for details.
PART 5: HANDLE PAGINATION
- CoinMarketCap limits the number of records returned in each request. By default, only 100 records will be returned unless you use the ‘start’ and ‘limit’ parameters as described in their documentation. The documentation says you can specify a limit of up to 5000, but in my own tests large limits seemed to produce an error, so I used 1000 in the examples below. YMMV.
To retrieve paginated records, add these ‘start’ and ‘limit’ parameters like this:
- With API Connector you can either run these request URLs manually or loop through them automatically with offset-limit pagination handling (paid feature), like this:
- API URL: enter your request URL as usual, making sure to include limit=1000
- Pagination type:
- Offset parameter:
- Limit parameter:
- Limit value:
- Number of pages: enter the number of pages you’d like to fetch
APPENDIX [PRO]: COINMARKETCAP TEMPLATE
In this template, everything is configured for you to simply add your API key along with whatever currencies you’re interested in and get a dashboard like below:
P.S. For dozens of other step-by-step guides for connecting crypto (and other) APIs to Google Sheets, click here: Knowledge Base