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:
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.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
To create the “app”, first login to https://my.freshbooks.com/#/developer and click the Create an App button:
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:
Your app will then be created. Click the arrow near the settings icon to reveal the client id and the client secret:
Copy and paste the values for your Secret and ID to a safe location, because you’ll need them in the next steps.
Click the Authorization URL link to obtain an authorization code:
In the next window, click the Allow button to continue:
The browser will navigate to your redirect URL and the authorization code will appear as a parameter named 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.
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:
Executing this command will return your access token in the response.
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.
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:
If you click a category (e.g Clients), the list of its specific endpoints will be expanded:
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:
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.
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.
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:
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: