Connecting 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 in Google Sheets

To pull data from the FreshBooks API to Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more.

1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the page: https://gsuite.google.com/marketplace/app/apipheny_api_tool/966163326746

Install Apipheny in the Google Workspace Marketplace
Install Apipheny in the Google Workspace Marketplace

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons or Extensions option in the top menu. In the add-ons menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

Open the Apipheny API add-on in your Google Sheet
Open the Apipheny API add-on in your Google Sheet after installing it

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

In your console window, 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"
Entering the command in the console window
Entering the command in the console window

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.

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//users/clients/

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/<accountid>/invoices/invoices

If you use this same URL, don’t forget to replace <account_id> with your account id. Do not include the brackets “<>”.

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

Headers

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>. Do not include the brackets “<>” around 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, such as:

  • Save and schedule your FreshBooks API request
  • Make a POST request to the FreshBooks API (if available)
  • Use the custom =APIPHENY() function to call the FreshBooks API request inside your spreadsheet
  • Create an API request by referencing the value of a cell in your FreshBooks API URL with three curly braces eg. {{{Sheet1!A1}}}

Related articles:

Related Posts