Crypto API tutorials and more:

Video Demo 1

How to import data from Coingecko into Google Sheets

Coingecko is a popular platform for getting cryptocurrency prices, market cap, trading volume, and more. We can use the Coingecko API to import crypto prices and other data into Google Sheets.

In this tutorial, I’ll show you how to connect the  Coingecko API to Google Sheets in 4 steps:

  1. Install the Apipheny Add-on
  2. Choose a Coingecko API endpoint
  3. Enter your Coingecko API request into Apipheny
  4. Run the Coingecko API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on for Google Sheets

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Choose a Coingecko API endpoint

In this section, we’ll show you how to browse the CoingeckoAPI documentation, to find the API URL that retrieves the information you need from your account. If you already know your URL, or you want to use the same example URL as us, just skip to Step 3.

First, open the CoingeckoAPI documentation page: https://www.coingecko.com/api/documentations/v3#/

A list of available endpoints will be displayed on the screen:

Coingecko API endpoints
Coingecko API endpoints

An example endpoint is GET Exchanges List, which obtains all the markets ids, in order to make API calls. This is the API URL for the endpoint:

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

The documentation for each endpoint contains the HTTP method (eg. GET) and the endpoint path, a short description of the endpoint’s purpose, a list of the accepted parameters and a table of the expected responses, for various content types:

Coingecko API endpoint example
Coingecko API endpoint example

Click the Try it out button to display and run an example cURL command, as well as its associated response:

Coingecko API endpoint example response
Coingecko API endpoint example response

All API calls to Coingecko should be made to the https://api.coingecko.com/api/v3/ base domain. All endpoints should be appended to this base URL.

More Coingecko API endpoint examples

The /coins/markets endpoint, which gets all the coins market data (price, market cap, volume):

Method: GET
API URL Path: https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1&sparkline=false
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

Don’t forget to add to the URL the required parameters. In this case vs_currency. In the endpoint’s documentation you can find other supported parameters.


The /coins/categories/list endpoint, which lists all categories:

Method: GET
API URL Path: https://api.coingecko.com/api/v3/coins/categories/list
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

This endpoint doesn’t have required parameters.


The /indexes endpoint which lists all market indexes:

Method: GET
API URL Path: https://api.coingecko.com/api/v3/indexes?per_page=20&page=1
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

This endpoint doesn’t have required parameters but has other ones, like per_page and page.


The /indexes/list endpoint, which lists market indexes id and name:

Method: GET
API URL Path: https://api.coingecko.com/api/v3/indexes/list
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

This endpoint doesn’t have required parameters or any other parameters.


The /derivatives endpoint, which lists all derivative tickers:

Method: GET
API URL Path: https://api.coingecko.com/api/v3/derivatives
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

This endpoint has just one optional parameter, include_tickers.

Coingecko API pagination

Pagination is a process that is used to divide a large dataset into smaller chunks (pages). Usually the endpoints that return a list of resources support pagination. 

Some of the Coingecko API endpoints use the pagination option. This means you need to add some of these parameters at the end of the URL:

  • page – the number of the page you want to obtain;
  • per_page – the number of records per page;

Each endpoint that needs pagination will have in its documentation relevant information on which of these parameters you can use and how to do it.

Example: https://api.coingecko.com/api/v3/indexes?per_page=20&page=3

In the example above, the data set will be divided in sets of 20 records per page, and only the third page (page number 3) will be displayed in Google Sheets.

Step 3.) Enter your Coingecko API request into Apipheny

Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your API endpoint. For this example, we are using the GET method.

API URL: In Step 2, we explained how you can find the CoingeckoAPI endpoint that you need. Now copy and paste your complete CoingeckoAPI URL into the Apipheny add-on, where it says API URL Path, followed by any parameters required for your query (if applicable).

For this example, we are using the Coin list endpoint, which lists all supported coins, as id, name and symbol. This is what the whole URL looks like:

https://api.coingecko.com/api/v3/coins/list?include_platform=true

If you’re following the same example as us, you can copy and paste this URL into Apipheny.

Headers: In the Headers section of Apipheny, add one row with the following key and value:

Header
Key:
Accept

Value:
application/json

Here’s what our Coingecko API request looks like in Apipheny:

Coingecko API request in Google Sheets using Apipheny
Coingecko API request in Google Sheets using Apipheny

Step 4.) Run the Coingecko API request in your Google Sheet

Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the Coingecko API data to be imported into your Google Sheet. Here’s what our request looked like when completed:

Coingecko API data in Google Sheets
Coingecko API data in Google Sheets

That’s it! You’ve successfully connected your Coingecko account to Google Sheets using the Coingecko API, Google Sheets API, and the Apipheny add-on.

After making a successful request to the CoingeckoAPI, try querying a different CoingeckoAPI endpoint, or try using one of the more advanced features in the Apipheny add-on.

Video Demo 2

Crypto API tutorials and more:


API Tutorials



API Knowledge

What is an API?
What is an API URL?
What are parameters?
What is an endpoint?
What is an API key/token?
What is basic authentication?
What are headers?
What is a GET request?
What is a POST request?


Crypto API tutorials and more: