Crypto API tutorials and more:

How to integrate the Coinbase API with Google Sheets

Coinbase is a secure platform that makes it easy to buy, sell, and store cryptocurrency like Bitcoin, Ethereum, and more. We can use the Coinbase API to import data from Coinase into Google Sheets. In this tutorial, we’ll show you how to connect the Coinbase API to Google Sheets in 4 steps:

  1. Install the Apipheny add-on
  2. Choose a Coinbase Endpoint
  3. Add your Coinbase API URL into the Apipheny add-on
  4. Run the Coinbase 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 Coinbase API Endpoint

In this section, we’ll show you how to browse the Coinbase API documentation to find the API URL with an endpoint 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 Coinbase API documentation page: https://developers.coinbase.com/api/v2

Coinbase documentation
Coinbase documentation

All Coinbase endpoint URLs are created by appending an endpoint-specific path to the root URL:

https://api.coinbase.com/v2/

Signed endpoints

Some Coinbase API endpoints require HMAC SHA256 and others don’t. This tutorial goes through examples that don’t require HMAC SHA256.

“Signed” Coinbase API endpoints that require HMAC SHA256 will not currently work with Apipheny, but endpoints that do not require HMAC SHA256 will work, such as the Get buy price endpoint we cover in the example below.

The reason signed endpoints don’t currently work with our app is because they require an additional parameter called signature, a keyed HMAC SHA256 signature with your secretKey as the key, and a concatenation of all the query’s parameters as the value passed to the HMAC operation. Signed endpoints also require a timeStamp parameter, populated with the request’s millisecond timestamp:

Coinbase API key
Coinbase API key

An example of a signed endpoint is the List transactions endpoint:

List transactions endpoint documentation
List transactions endpoint documentation

You can tell if an endpoint is signed or not, because when you look at the documentation for that endpoint, you’ll see the “This endpoint doesn’t require authentication” phrase. The presence of this phrase means that the endpoint is public (not signed and doesn’t require an API key, a token or a signature).

Public endpoints

Public endpoints can be accessed without an API key and a signature.

As explained before, to identify the public endpoints, you have to look for those which have the phrase “This endpoint doesn’t require authentication” in their documentation.

The only category from the Coinbase API documentation that contains public endpoints, which require no API key, is Data Endpoints: https://developers.coinbase.com/api/v2#data-endpoints

Data endpoints documentation
Data endpoints documentation

An example public endpoint that requires no key is Get buy price, which gets the total price to buy one bitcoin or ether. It uses the GET method and the URL for this endpoint is:

https://api.coinbase.com/v2/prices/BTC-USD/buy 

The endpoint’s documentation contains its HTTP method (GET), the URI, the cURL command and an example response:

Get buy price endpoint documentation
Get buy price endpoint documentation

Step 3.) Add your Coinbase API URL into the Apipheny add-on

In this section, we’ll show you how to enter your Coinbase API request into Apipheny. This section explains how to enter a supported API request, one that doesn’t require an API key.

Back in your Google Sheet, make sure the Apipheny add-on is open, on the Import tab.

After you’ve found the endpoint you need in Step 2, copy the complete URL into the API URL Path field in the Apipheny add-on, followed by any GET parameters required for your query (see screenshot below).

Here’s the example URL endpoint we used, which doesn’t require an API key:

https://api.coinbase.com/v2/prices/currency_pair/buy

This API URL is the Get buy price endpoint, which returns the total price to buy one bitcoin or Ether. If you use this URL, don’t forget to replace currency_pair with a real value.

At the top of the add-on select the HTTP method (GET or POST) required by your API endpoint. For this example, we are using GET.

Headers are not required for public endpoints, so you can leave the Headers section blank in Apipheny.

Coinbase API request entered into Apipheny
Coinbase API request entered into Apipheny

Step 4.) Run the Coinbase 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 Coinbase API data to be imported into your Google Sheet. Here’s what our request looked like when completed:

Coinbase data imported into Google Sheets - Get buy price endpoint
Coinbase data imported into Google Sheets – Get buy price endpoint

More Example Coinbase API Requests

Get sell price, which gets the total price to sell one bitcoin or ether. It uses the GET method and its URL is:

https://api.coinbase.com/v2/prices/currency_pair/sell

Don’t forget to replace currency_pair with a real value.

To use this endpoint, just copy and paste this URL into Apipheny. After you enter the URL into the add-on, click the “Run” button at the bottom of the Apipheny add-on and the data will be imported into your Sheet, as shown in this screenshot:

Coinbase data imported into Google Sheets - Get sell price endpoint
Coinbase data imported into Google Sheets – Get sell price endpoint

– Get exchange rates which returns the current exchange rates. The default base currency is USD,  but it can be defined as any supported currency. Returned rates will define the exchange rate for one unit of the base currency. It uses the GET method and its URL is:

https://api.coinbase.com/v2/exchange-rates

To use this endpoint, just copy and paste this URL into Apipheny. After you enter the URL into the add-on, click the “Run” button at the bottom of the Apipheny add-on and the data will be imported into your Sheet, as shown in this screenshot:

Coinbase data imported into Google Sheets - Get exchange rates endpoint
Coinbase data imported into Google Sheets – Get exchange rates endpoint

– Get currencies which lists all currencies known by Coinbase. It uses the GET method and its URL is:

https://api.coinbase.com/v2/currencies

To use this endpoint, just copy and paste this URL into Apipheny. After you enter the URL into the add-on, click the “Run” button at the bottom of the Apipheny add-on and the data will be imported into your Sheet, as shown in this screenshot:

Coinbase data imported into Google Sheets - Get currencies endpoint
Coinbase data imported into Google Sheets – Get currencies endpoint

That’s it! You’ve successfully learned how to connect your Coinbase account to Google Sheets using the Coinbase API, Google Sheets API, and the Apipheny add-on.

After making a successful request to the Coinbase API, try querying a different Coinbase API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:


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?