Import CoinGecko Cryptocurrency Data into Google Sheets

Screenshot_288

With over 4,800 cryptocurrencies and over 330 exchanges tracked, CoinGecko has one of the most comprehensive cryptocurrency databases in the world. We have received several requests for our data to be made available on Google Sheets.

This is a simple 3 step guide to get your portfolio the most updated price, market capitalization, trading volume and all the other information that you will need in your spreadsheet.

Step 1: Add an ImportJSON script to your Google Sheets

In your Google Sheets, go to the tools section and select “<> Script editor”. Once the script editor is open, replace all the existing code with the following code:

/**
* Imports JSON data to your spreadsheet
* @param url URL of your JSON data as string
* @param xpath simplified xpath as string
* @customfunction
*/
function IMPORTJSON(url,xpath){

try{
// /rates/EUR
var res = UrlFetchApp.fetch(url);
var content = res.getContentText();
var json = JSON.parse(content);

var patharray = xpath.split(".");
//Logger.log(patharray);

for(var i=0;i<patharray.length;i++){
json = json[patharray[i]];
}

//Logger.log(typeof(json));

if(typeof(json) === "undefined"){
return "Node Not Available";
} else if(typeof(json) === "object"){
var tempArr = [];

for(var obj in json){
tempArr.push([obj,json[obj]]);
}
return tempArr;
} else if(typeof(json) !== "object") {
return json;
}
}
catch(err){
return "Error getting data"; 
}
}

Save the code and rename it as “ImportJSON”. Close the script editor and return to your spreadsheet.

Step 2: Find the API endpoint you need

CoinGecko offers a comprehensive set of crypto data in our CoinGecko API. For this exercise, we will be using the /coins/list endpoint to identify the api ID of the specific coins and /coins/markets endpoint to obtain the market data.

To obtain the price of Bitcoin, the /coins/markets endpoint would be:

https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin

Step 3: Import data using ImportJSON formula and CoinGecko API

The ImportJSON formula:

=ImportJSON (“[API URL]”,”[JsonPath]”

If you are unfamiliar with JsonPath implementation, you can refer to JsonPath’s github which includes comprehensive explanation on JsonPath. Combining the ImportJSON formula and CoinGecko API, you will get the desired data. Below are examples of the formula to obtain Bitcoin data.

Bitcoin price:

=importJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin","0.current_price")

Bitcoin market capitalization:

=importJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin","0.market_cap")

Bitcoin 24 hours volume:

=importJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin","0.total_volume")

Bitcoin All Time High price:

=importJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin","0.ath")

Bitcoin circulating supply:

=importJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin","0.circulating_supply")

Bitcoin historical price on 30th May 2019, 00:00 UTC:

=ImportJSON("https://api.coingecko.com/api/v3/coins/bitcoin/history?date=30-5-2019","market_data.current_price.usd")

Bitcoin historical market capitalization on 30th May 2019, 00:00 UTC:

=ImportJSON("https://api.coingecko.com/api/v3/coins/bitcoin/history?date=30-5-2019","market_data.market_cap.usd")

Bitcoin historical 24 hours volume on 30th May 2019, 00:00 UTC:

=ImportJSON("https://api.coingecko.com/api/v3/coins/bitcoin/history?date=30-5-2019","market_data.total_volume.usd")

Using the ImportJSON formula and CoinGecko API, you can easily obtain all the information that you need for your cryptocurrency watchlist or portfolio tracking in Google Sheets. There are other CoinGecko API endpoints available as well which you are free to experiment with.

Here is a sample of our completed Google Sheets for the most popular cryptocurrencies. Feel free to make a copy and modify it for your own use!

Updated 17 August 2020: Some of you prefer seeing your favorite coins in a different manner. We have added a new template to our Google Sheets template. Here is a preview which you can make a copy and edit further.

Additionally, we frequently get questions about the API ID for many tokens. You may refer to this Google Sheets to see the API ID associated with each token listed on CoinGecko, sorted in alphabetically order.

If you would like to import data into Microsoft Excel, Cryptosheets may be a tool that you may use to query CoinGecko’s data.

Share on twitter
Twitter
Share on telegram
Telegram
Share on facebook
Facebook
Share on linkedin
LinkedIn
Share on email
Email

56 thoughts on “Import CoinGecko Cryptocurrency Data into Google Sheets”

    1. I have tried this

      =ImportJSON(“https://api.coingecko.com/api/v3/global”,”total_market_cap.usd”)

      But, the response was:
      Error getting data

  1. Hello,
    I was wonder if I could do this in a more efficient way. For example If I’m tracking 100 coins then when I load my spreadsheet I’m doing 100 API calls. Is there a way to do one API call that will go into a tab and I can reference that info for the rest of the spreadsheet info. I’m only pulling the price of the coins.

        1. Yes, you need to pull from the coins/markets api. so for btc and eth you would enter:
          https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin%2C%20ethereum%2C%20&page=1&sparkline=false
          You can enter as many currencies as you want. Then when you import its only 1 call. The easiest way is to use the tools here to look up the correct names of the coins in the database and enter them: https://www.coingecko.com/en/api
          Use the get coins and search for the correct name to enter in the markets call. some names are old or different from what you would expect

        2. Did someone find a solution. I am also having the same issue. It keeps making several hundreds of calls and many of them fail to load data in the end. I want to be able to make one call download all the data and play with it. Will just keep downloading fresh data at defined intervals

  2. Thanks for sharing this article! Article is nice. very informative.

    If you want to hire top rated Crypto Developers for Develope ICO development, STO development, IEO development, real estate tokenization, art tokenization, stable coin development, crowd funding platform, local Bitcoin clone, crypto payment development. We are a team of professional blockchain developers.

    Thanks

  3. Putin’s Personal Trader Exposes How To Turn $10 To $100K
    Renegade Russian Analyst Reveals How To Turn $10 To $100K
    Have you seen this viral video?
    The Cryptocurrency Institute have released a video show casing the methods a Putin’s Cryptocurrency Traders uses to generate 10,000% ROI!
    [Click here to watch this before it’s taken down]
    This is shocking.
    I didn’t believe this myself until I saw it.
    See for yourself.
    It will blow you away.

  4. What happened to the CoinGecko Google Sheets Add-On? I was using it happily for many months, and today it just vanished without trace from my cryptotracking G-Sheet, and there’s no sign of it in the G-Suite Marketplace. Made it super-easy to include price data, without having to include an ImportJSON script!

    1. Same here. I was using this function: =COINGECKO(“BTC/USD”)
      It’s been working for many months and I now get a message saying that this is an unknown function.
      CoinGecko, can you tell us what’s going on?

  5. Gecko team, are you going to fix the add-on?
    Regarding the Jason script, how often the price will refresh – =importJSON(“https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin”,”0.current_price”)?

  6. I don’t think the CoinGecko Google Sheets Add-On was made by the CoinGecko team — it appears to be a completely separate project:

    https://github.com/coingecko/coingecko-gsheet-addon

    A real shame, as it made it super-easy to use the CoinGecko API!

    My guess is that it stopped working due to the CoinGecko API being changed, since the sample Google Sheet linked to in this article also doesn’t work any more, either (prices are from 2019).

  7. Ignore my comment above — seems like the Coingecko Add-On *was* an official Coingecko preoduct after all.

    Which makes it’s disappearance from the Google Marketplace even more mysterious!

    Anyone know how to edit the script in the sample GSheet refresh the values? They’re stuck at 25 September 2019!

  8. How do you get the script to refresh? The data doesn’t change unless I open the script editor and click ‘save’… I have a button with assigned script to run the function IMPORTJSON and although it appears to run the script, the data doesn’t update. Can anyone help?

  9. Same problem here. I was using the Coingecko ADD-ON in my Google Sheet, but it’s not working anymore. Can’t find the add-on anywhere.

    Now my whole Google Sheet is not able to display prices. The function =COINGECKO(“BTC/USD”) was really useful, but now it’s missing.

    If anyone knows an alternative, please let us know.

  10. Great, I was able to import the current price of the coin I’m interested in.

    But now I noticed that the price doesn’t update. I’ve tried waiting, refreshing the web page, and completely closing out of the page and reloading. The only way I can get it to update is to redo the formula in the cell(ie copy/paste) This is kind of redundant and the whole reason I wanted the data pulled from the site in the first place. So that I didn’t have to do any more copy and pasting.

    Am I missing something?

    1. If you’re using the Cryptosheets add-on in Google or Excel try these:

      Just BTC dominance:
      (Excel) =CS.QUERYA(“CoinGecko”,”Global”,”_path”,”data.market_cap_percentage”,”_fields”,”btc”)
      (Googlesheets) =CSQUERYA(“CoinGecko”,”Global”,”_path”,”data.market_cap_percentage”,”_fields”,”btc”)

      >> List of Top 10 Market Cap w/ Dominance (%) for Each
      (Excel) =TRANSPOSE(CS.QUERYA(“CoinGecko”,”Global”,”_path”,”data.market_cap_percentage”))
      (Googlesheets) =TRANSPOSE(CSQUERYA(“CoinGecko”,”Global”,”_path”,”data.market_cap_percentage”))

  11. why do some coins you get “error getting data”, and others don’t? I know some don’t have a data on the website, like M Cap, but still happens to some that do?

  12. I’m running the script to run the function IMPORTJSON: what name do I use to retrieve the price for Bitcoin SV? I’ve tried:
    Bitcoin SV
    Bitcoin_SV
    BitcoinSV
    BSV
    BTCSV
    BSVUSD
    BSV/USD
    Thanks

  13. If anyone is having trouble refreshing their rates in Google Sheets you can add an additional parameter that references any cell and that cell can be used to trigger a query of the API.

    Ex. =importJSON(“https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=ethereum”,”0.current_price”,A1)

    Now all you need to do is update the A1 cell (any value should work) and it will trigger any API calls that include this cell as an additional parameter.

  14. What is happening with this GoCrypto (GOC)? I invested in it through Hotbit. The same day hotbit is not showing it, the value is going up. What should I do? Now is showing:

    1
    Bitcoin.com Bitcoin.com GOC/ETH $0.02093902 1.97% $38 $82 $30
    0.38% about 1 hour ago
    2 TokensNet TokensNet GOC/ETH $0.01942893 – – – $7,698
    96.54% Recently –
    3 Bitcoin.com Bitcoin.com GOC/BCH $0.02075875 1.5% $609 $94
    $230
    2.88% Recently

    Regards
    Conie

  15. Is there a way to reference the ID from a specific cell? For example the formula: =importJSON(“https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin”,”0.current_price”)

    The above references the actual ID in the formula itself (“bitcoin”) where as I want the formula to reference a specific cell where the ID is i.e A1 for example. And then drag that down for 100 coins so I can get the price for 100 coins/IDs by having the formula reference A1,A2,A3,A4 etc. rather than having to manually type in the ID “bitcoin”, “ethereum”, “polkadot” into the formula each time?

    1. If you use the Cryptosheets add-on for Googlesheets, these formulas should work and give you exactly what you’re looking for:

      =CSQUERYA(“CoinGecko”,”Simple Price”,”ids”,”bitcoin”,”vs_currencies”,”usd”)

      =CSQUERYA(“CoinGecko”,”Simple Price”,”ids”,A1,”vs_currencies”,A2)
      *where A1 = bitcoin and A2 = usd

    2. Nick, did you find a solution to your questions.

      I’ve been trying for the last couple of hours w/o any solution in sight.

      My approach: I’ve created the whole input for importjson in a cell. However when I do importjson(D2). Assume D2 has necessary string to fetch data for bitcoin, it doesn’t work.

      An online search tells me indirect function could be of help, but still, I’m not able to make it work.

      did anyone make it work?

  16. Hi CoinGecko Spreadsheet Users!

    I have some great news for all of you and some simple, free solutions to try right now that can resolve basically every recent question/comment on this blog post!

    We have been working with the CoinGecko team to fully integrate the entire Coingecko API into the Cryptosheets Excel & Googlesheets add-ons (see below for instructions to get your exclusive CoinGecko user discount!)

    # HOW IT WORKS
    – All CoinGecko API endpoints are fully integrated, parameterized and searchable inside Excel & Googlesheets using the Cryptosheets add-on
    – Send data directly to your sheets through the side panel query builder and API console
    – Pull data into any cells in your sheets using simple, familiar formulas then refresh them live or at any interval you want
    – Try pre configured sample queries/formulas and explore dedicated support resources, tutorials, videos & quick start templates for every single endpoint

    # EXAMPLES
    TIP: just copy + paste the formulas into your spreadsheet… it’s that easy

    >> Googlesheets
    ——————————————-
    =CSQUERYA(“CoinGecko”,”Coins Markets”,”vs_currency”,”usd”)
    =CSQUERYA(“CoinGecko”,”Coins Markets”,”vs_currency”,”usd”,”_fields”,”symbol,total_supply,current_price,market_cap”)
    =CSQUERYA(“CoinGecko”,”Simple Price”,”ids”,”bitcoin”,”vs_currencies”,”usd”)
    =CSQUERYA(“CoinGecko”,”Simple Price”,”ids”,A1,”vs_currencies”,A2) –> where A1 = bitcoin and A2 = usd

    =CSQUERYA(“CoinGecko”,”Coins Market Chart”,”vs_currency”,”usd”,”days”,”14″,”id”,”bitcoin”)
    =CSQUERYA(“Coingecko”,”derivatives”)
    =CSSYMBOLS(“exchange”,”coingecko”,”_limit”,”8000″,”_orderBy”,”symbol”)

    >> Microsoft Excel
    ——————————————-
    =CS.QUERYA(“CoinGecko”,”Coins Markets”,”vs_currency”,”usd”)
    =CS.QUERYA(“CoinGecko”,”Coins Markets”,”vs_currency”,”usd”,”_fields”,”symbol,total_supply,current_price,market_cap”)
    =CS.QUERYA(“CoinGecko”,”Simple Price”,”ids”,”bitcoin”,”vs_currencies”,”usd”)
    =CS.QUERYA(“CoinGecko”,”Simple Price”,”ids”,A1,”vs_currencies”,A2) –> where A1 = bitcoin and A2 = usd

    =CS.QUERYA(“CoinGecko”,”Coins Market Chart”,”vs_currency”,”usd”,”days”,”14″,”id”,”bitcoin”)
    =CS.QUERYA(“Coingecko”,”derivatives”)
    =CS.SYMBOLS(“exchange”,”coingecko”,”_limit”,”8000″,”_orderBy”,”symbol”)

    # RESOURCES
    Cryptosheets WebApp: https://app.cryptosheets.com/#/browse/coingecko
    Cryptosheets Docs Portal:
    https://docs.cryptosheets.com/providers/coingecko
    https://docs.cryptosheets.com/providers/coingecko/finance-products/

    Templates:
    https://docs.cryptosheets.com/templates/coingecko-query-builder
    https://docs.cryptosheets.com/templates/crypto-exchange-rankings-dashboard/
    https://app.cryptosheets.com/#/templates/386
    https://app.cryptosheets.com/#/templates/428

    Help Center: https://intercom.help/cryptosheets/en/collections/2418653-providers#coingecko
    YouTube: (Cryptosheets/CoinGecko playlist) :https://www.youtube.com/playlist?list=PLBg8GR5ao-axSqTrwnAodL2YVVqzFjYlO

    # EXCLUSIVE DISCOUNTS FOR COINGECKO USERS
    1. Check the settings > candy > rewards section in your CoinGecko user profile/settings

    2. MAKE SURE to visit the CoinGecko/Cryptosheets referral page:
    https://cryptosheets.com/partners/coingecko
    – Enter your email to automatically get a 25% discount if/whenever you upgrade to a paid Cryptosheets subscription!

    3. Install the Microsoft & Google approved add-ons directly from the add-on stores:
    – Googlesheets: https://gsuite.google.com/u/2/marketplace/app/cryptosheets/898843532532
    – Excel: https://appsource.microsoft.com/en-us/product/office/WA104381695

    4. Explore the Cryptosheets platform and use/access CoinGecko data for free –> starting RIGHT NOW!

  17. Hi is there a way to download a time series into google sheet?
    Tried this:

    =ImportJSON(“https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=14″,”prices”)

    and all i got is a series of running numbers. any experts?

  18. This is so painful. I just want to code the API myself without depending on any third party add on’s. Why can’t I download all the symbol data in one shot and then use json to parse and read values. IT IS SO INEFFICIENT TO USE URL FOR EACH VALUE MAKING THOUSANDS TO INDIVIDUAL CALLS.

  19. Thanks, man.
    Not sure why with importjson I get the message – error getting data.

    Is it happening with others? Any workaround?

    =IMPORTJSON(“https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=1h%2C%2024h%2C%207d%2C%2030d%2C%201y%2C%202y”)

Leave a Comment

Your email address will not be published. Required fields are marked *