Import Harvest Data to Google Sheets
Harvest is a popular time tracking and invoicing tool that provides numerous integrations, but no official integration for Harvest and Google Sheets. In this guide, we’ll walk through how to pull data from the Harvest API directly into Google Sheets, using the API Connector add-on for Sheets.
- Before You Begin
- Part 1: Connect to the Harvest API
- Part 2: Get your Harvest Account ID
- Part 3: Create your API Request URL
- Part 4: Pull Harvest API Data into Sheets
- Part 5: More Example API URLs
- Part 6: Handle Filters
- Part 7: Handle Pagination
- Appendix: Connect with a Personal Access Token
BEFORE YOU BEGIN
Click here to install the API Connector add-on from the Google Marketplace.
PART 1: CONNECT TO THE HARVEST API
If you haven’t connected to the Harvest API before, you’ll first need to initiate the connection.
- Open up Google Sheets and click Add-ons > API Connector > Manage Connections.
- In the list of available connections, find Harvest and click Connect.
- You will see a modal asking you to approve the connection. Click Authorize App.
- You’ll then be returned to your Google Sheet, and can verify that your GitHub connection is active in the Connections screen.
PART 2: GET YOUR HARVEST ACCOUNT ID
Harvest requires that you pass your account ID into a header when making requests to the API. This is actually pretty useful if you’re working with multiple Harvest accounts, since it enables you to differentiate between them.
Therefore, as a precursor to getting data, let’s first find out our account ID. In API Connector, open up the Create tab and enter the following URL:
Under Authentication, choose Harvest. Choose an output sheet and click Run and you should see your account ID(s) returned into a sheet, under the field name
accounts » id. Mark this ID down as we’ll need it shortly.
PART 3: CREATE YOUR HARVEST API REQUEST URL
OK, now let’s get some real data. We’ll start with time entries.
- API root: https://api.harvestapp.com/v2
- Endpoint: /time_entries
- Parameters: ?page=PAGE_NUMBER
Parameters Example: ?page=1
The ‘page’ parameter is optional but we’ll include it to show how parameters work. Putting it all together, we get the full API Request URL:
PART 4: PULL HARVEST API DATA INTO SHEETS
Let’s get that Harvest time entry data into Google Sheets.
- Open up Google Sheets and click Add-ons > API Connector > Open.
- In the Create screen, enter the Request URL we just created:
- Under Headers, enter your account ID from above as a Header, like this:
- Choose “Harvest” from the drop-down authentication menu.
- Create a new tab and click ‘Set current’ to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see Harvest data populate your Google Sheet:
PART 5: MORE EXAMPLE API URLS
You can check the documentation for the full list of available API requests, but if you just want to jump in, you can play around with the URLs you enter in the API URL path field. Try the following (one at a time):
PART 6: HANDLE FILTERING
You may want to limit your pulls for certain client IDs or time ranges. You can combine parameters like this:
https://api.harvestapp.com/v2/time_entries?client_id=1234567&page=1 (you can find your client ID in the “clients” table).
PART 7: HANDLE PAGINATION
Harvest limits the number of records returned in each request. By default, only 100 records will be returned unless you use the ‘page’ parameter as described in their documentation.
Each page contains 100 records. To access more than 100 records, edit the “page” parameter to your URL path, like this:
With API Connector you can either run these request URLs manually or loop through them automatically with pagination handling (paid feature). Harvest provides a “next page URL” so we’ll use that type.
- API URL: enter your request URL as usual
- Pagination type:
next page URL
- Field name:
- Number of pages: enter the number of pages you’d like to fetch
APPENDIX: CONNECT WITH A PERSONAL ACCESS TOKEN
- Sign into Harvest and navigate to their Developer Tools page (https://id.getharvest.com/developers)
- Click “Create New Personal Access Token”
- Give it a name and click “Create Personal Access Token”. You can name it anything, but we’ll call it ‘Google Sheets’ here.
- You should now see a page containing all your API access details. Congrats! You’re now ready to access the Harvest API. Keep these details handy as we’ll need them in a moment.
- Enter these values into the Headers section, like this. You’ll also need to include your email address for the User-Agent key. The whole thing should look something like this: