How to connect Freshbooks to Google Sheets

Freshbooks is a popular invoice and accounting software. We can use the Freshbook API to import data from Freshbooks into Google Sheets. In this tutorial, you will learn how to connect the FreshBooks API to Google Sheets in 7 steps:

  1. Install the Apipheny Add-on
  2. Create a Freshbooks API App
  3. Obtain an Authorization Code
  4. Get an Access Token
  5. Choose your Endpoint URL
  6. Enter the FreshBooks API URL into Apipheny
  7. Run the Freshbooks 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.) Create a Freshbooks API app

To create the “app”, first login to https://my.freshbooks.com/#/developer and click the Create an App button:

Create a Freshbooks App
Create a Freshbooks App

Enter an application name, the description, the website URL, the application settings URL and the redirect URL, then click the Save button in the top-right corner:

Enter the app details and click "Save"
Enter the app details and click “Save”
Don't forget to enter a Redirect URI, which can be your website URL
Don’t forget to enter a Redirect URI, which can be your website URL

Your app will then be created. Click the arrow near the settings icon to reveal the client id and the client secret:

Click the small arrow
Click the small arrow
Copy and paste your client ID and client Secret values to a safe location

Copy and paste the values for your Secret and ID to a safe location, because you’ll need them in the next steps.

Step 3.) Obtain an Authorization Code

Click the Authorization URL link to obtain an authorization code:

Click on "Authorization URL"
Click on “Authorization URL”

In the next window, click the Allow button to continue:

Click "Allow"
Click “Allow”

The browser will navigate to your redirect URL and the authorization code will appear as a parameter named code:

Your authorization code will be in your browser bar, after “code=”

Your authorization code will be displayed in your browser address bar, after “code=”. Copy and paste your authorization code to a safe location, because you’ll need them in the next steps.

Step 4.) Get an Access Token

Open up a command prompt window (for Windows OS) or a terminal (for Mac OS) and enter the command below to obtain a token:

curl -X POST -H "Content-Type: application/json" -d "{\"grant_type\": \"authorization_code\",\"client_id\": \"CLIENT_ID\",\"code\": \"AUTHORIZATION_CODE \",\"client_secret\":\"CLIENT_SECRET\",\"redirect_uri\": \"REDIRECT_URI\"}" "https://api.freshbooks.com/auth/oauth/token"

You’ll need to replace a few values in the code:

  • AUTHORIZATION_CODE is the value of the code parameter from the previous step
  • CLIENT_ID and CLIENT_SECRET are the two values you copied in Step 2, after creating your app
  • REDIRECT_URI is the redirect URI that you filled when you created your app, use the same URI/URL

Executing this command will return your access token in the response.

Entering the command in the console window
Entering the command in the console window
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).
Note: If the token/key that you generate has an expiration time, you will need to complete this same process again to get a new token when the old one expires.

Step 5.) Obtain an Endpoint URL

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

First, open the FreshBooks API documentation page: https://www.freshbooks.com/api/start

On the API documentation page, the menu on the left contains the Setup, the Scenarios and Concepts, the Tutorial and the Authorization sections, as well as a list of categories, each with its own endpoints:

Freshbooks API categories
Freshbooks API categories

If you click a category (e.g Clients), the list of its specific endpoints will be expanded:

Freshbooks API endpoints example
Freshbooks API endpoints example

An example endpoint is Get Single Client, which retrieves a single client’s data from your FreshBooks account, by its ID. The URL for this endpoint would be:

https://api.freshbooks.com/accounting/account/accountid/users/clients/id

If you use this URL, don’t forget to replace accountid and id with your actual values.

Each endpoint’s documentation contains its HTTP method (GET), its URI, a sample response, a short description of the endpoint’s purpose, as well as sections for the details which can be included in the response, for searches and filters and for the field’s descriptions:

Freshbooks API endpoint documentation
Freshbooks API endpoint documentation

All API calls to the FreshBooks API should be made with this base URL:

https://api.freshbooks.com/

All endpoints should be appended to this URL.

Step 6.) Enter the FreshBooks API request into Apipheny

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 5, we explained how you can find the FreshBooks API endpoint that you need. Now copy the complete URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query (if applicable).

For this example we are using the List Invoices endpoint, which gets all the invoices from your account. The corresponding URL for this endpoint is:

https://api.freshbooks.com/accounting/account/account_id/invoices/invoices

If you use this same URL, don’t forget to replace account_id with your account id.

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

Header
Key:
Authorization
Value:
Bearer your_token

your_token is the value of the token you obtained previously, in Step 4. There should be a space between Bearer and your_token.

Freshbooks API request entered into the Apipheny add-on
Freshbooks API request entered into the Apipheny add-on

Step 7.) Run the FreshBooks API Request

Lastly, click the Run button at the bottom of the Apipheny add-on and then wait for your FreshBooks API data to be retrieved and added to your Google spreadsheet:

Freshbooks connected to our Google Sheet and data imported
Freshbooks connected to our Google Sheet and data imported

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

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


Crypto API Tutorials:


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?