How to connect Hubspot to Google Sheets

HubSpot offers a broad range of marketing, sales, and customer service software that works together with their core CRM product. Their various packages and platforms feature a significant degree of interoperability, creating a powerful business-focused ecosystem.

In this tutorial, you’ll learn how to connect the Hubspot REST API to Google Sheets in 5 steps using the Apipheny add-on:

  1. Install the Apipheny add-on
  2. Get your Hubspot API token
  3. Choose a Hubspot endpoint URL
  4. Enter the Hubspot API request into Apipheny
  5. Run the Hubspot API request

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.) Get your Hubspot API token

1. In your HubSpot account, click the Settings icon in the main navigation bar:

Click Settings
Click Settings

2. In the left sidebar menu, navigate to Integrations > Private Apps:

Integrations section
Integrations section

3. In the Private Apps section click the Create a private app button:

Private Apps section
Private Apps section

4. Choose a name and a logo and write a description for your app:

App's Basic Info
App’s Basic Info

5. Go to the Scopes tab, choose the scopes that you want for your app and then click the Create app button:

App's scopes
App’s scopes

6. In the Create a new private app popup click the Continue creating button:

Create new private app popup
Create new private app popup

7. Your private app was created and your token was generated. You can copy the token to a safe location after you click the Show button link:

Token generation
Token generation

Step 3.) Obtain a Hubspot endpoint URL

In this section, we’ll show you how to browse the Hubspot API documentation to find an endpoint that retrieves the specific information you need from your Hubspot account.

If you already know your URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the Hubspot API documentation page: https://developers.hubspot.com/docs/api/overview

The menu on the left, starting with Analytics API, contains a list of the available APIs each with its own endpoints.

Hubspot API Documentation
Hubspot API Documentation

Clicking on an API takes you to that API’s section, containing a list of associated endpoints. If we click the Inbox and messages API it’s endpoints will be displayed:

Inbox and messages API
Inbox and messages API
Inbox and messages API endpoints
Inbox and messages API endpoints

One of the available endpoints, the one we’re using in this example, is Get a single actor:

https://api.hubapi.com/conversations/v3/conversations/actors/{actorId}

Each endpoint’s documentation contains the HTTP method used (GET), a short description of the endpoint’s purpose, example CURL request, accepted parameters and an example response:

Get a single actor endpoint documentation
Get a single actor endpoint documentation

All API calls to HubSpot should be made to the https://api.hubapi.com root domain:

https://api.hubapi.com

More Hubspot API endpoint examples

The Get all Landing Pages endpoint, which gets the list of landing pages:

Method: GET
API URL Path: https://api.hubapi.com/cms/v3/pages/landing-pages
Headers:
    Header 1 Key:
       Authorization
    Header 1 Value:
       Bearer your_token

your_token, is the value you previously obtain at Step 2.).


The Get all Landing Page Folders endpoint. which gets the list of Landing Page Folders:

Method: GET
API URL Path: https://api.hubapi.com/cms/v3/pages/landing-pages/folders
Headers:
    Header 1 Key:
       Authorization
    Header 1 Value:
       Bearer your_token

your_token, is the value you previously obtain at Step 2.).


The Get indexed properties endpoint, which for a given account and document ID (page ID, blog post ID, HubDB row ID, etc.), return all indexed data for that document:

Method: GET
API URL Path: https://api.hubapi.com/cms/v3/site-search/indexed-data/
Headers:
    Header 1 Key:
       Authorization
    Header 1 Value:
       Bearer your_token

your_token, is the value you previously obtain at Step 2.).

Hubspot 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 Hubspot API endpoints use the pagination option. This means you need to add some of these parameters at the end of the URL:

  • after – The paging cursor token of the last successfully read resource will be returned as the paging.next.after JON property of a paged response containing more results.
  • limit – The maximum number of results to display per page. Default value is 500.

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.hubapi.com/crm/v4/objects/contacts/associations/?after=NTI1Cg%3D%3D&limit=500

In the example above, the data set will be divided in sets of 500 records per page, and only the page after last successfully read resource (after=NTI1Cg%3D%3D) will be displayed in Google Sheets. If this is the first call, then you don’t need the after parameter.

Step 4.) Enter the Hubspot API URL 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 3, we explained how you can find the Hubspot REST API endpoint that you need. Now copy the complete URL (root domain + endpoint) into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.

For this example, we are using the GET /account-info/v3/details endpoint, to get all contacts:

https://api.hubapi.com/account-info/v3/details

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

Header
Key:
Authorization
Value:
Bearer your_token

your_token, is the value you previously obtain at Step 2.). There should be a space between Bearer and your_token.

Here’s what our API request looked like:

Hubspot API request entered in Apipheny
Hubspot API request entered in Apipheny

Step 5.) Run the Hubspot API request

Click the Run button at the bottom of the Apipheny add-on and then wait for the Hubspot API data to be added to your Google Sheet:

Hubspot API data in Google Sheets
Hubspot API data in Google Sheets

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


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?