Search API Connector Documentation

Print

Import Harvest Data to 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.

There are 2 ways to connect to the Harvest API:

  • Preset “Connect” button (OAuth) premium
  • Personal access token. Please check the appendix for detailed instructions to retrieve your token.

Contents

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.

  1. Open up Google Sheets and click Extensions > API Connector > Manage Connections.
  2. In the list of available connections, find Harvest and click Connect.
    harvest-img1
  3. You will see a modal asking you to approve the connection. Click Authorize App.
    harvest-img2
  4. You’ll then be returned to your Google Sheet, and can verify that your Harvest 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:

https://id.getharvest.com/api/v2/accounts

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.

harvest-accountid

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:

https://api.harvestapp.com/v2/time_entries?page=1

Part 4: Pull Harvest API Data into Sheets

Let’s get that Harvest time entry data into Google Sheets.

  1. Open up Google Sheets and click Extensions > API Connector > Open.
  2. In the Create screen, enter the Request URL we just created:
    harvest-url
  3. Choose “Harvest” from the drop-down authentication menu. It should say ‘Connected’.
    harvest-connected
  4. Under Headers, enter your account ID from above as a Header, like this:
    Harvest-Account-IdYOUR_ACCOUNT_ID
    harvest-headers
  5. Create a new tab and click Set current to use that tab as your data destination.
  6. Name your request and click Run. A moment later you’ll see Harvest data populate your Google Sheet:
    harvest-results1

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).

You can also use API Connector’s API Library (just search for “Harvest” while in the add-on) to easily pull up most of these sample requests.

https://api.harvestapp.com/v2/time_entries
https://api.harvestapp.com/v2/clients
https://api.harvestapp.com/v2/invoices
https://api.harvestapp.com/v2/tasks
https://api.harvestapp.com/v2/expenses
https://api.harvestapp.com/v2/projects

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).

If you don’t need all the fields returned by Harvest, click Edit Fields before you run your request. This will open API Connector’s visual field editor, where you can choose the columns you’d like to display in your sheet.

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’ and ‘per_page’ parameters as described in their documentation.
harvest-pagination

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 enter it like this:

  • API URL: enter your request URL
  • Pagination type: next page URL
  • Next page path: links.next
  • Run until: choose when to stop fetching data
    pagination-nextpageurl

Part 8: Fetch New Data Only

You may want to fetch new data only rather than repeatedly retrieve data you already have in your sheet. Harvest provides various time parameters we can use for this purpose.
harvest-timeparameters

Here’s one way to apply these to your request:

  1. Fetch existing data into a sheet (let’s call it TimeEntries), and find the column containing your spent date.
    harvest-spentdate
  2. Create a second sheet called MaxDate and input this formula: =text(max('API key'!B:B),"yyyy-mm-dd")
    harvest-maxdate
  3. That formula grabs the most recent spent date, and converts it to yyyy-mm-dd format. Update your time entries API request to reference that cell, like this: https://api.harvestapp.com/v2/time_entries?from=+++MaxDate!A1+++
    harvest-appendurl
  4. Run that request in append mode, sending to the same TimeEntries sheet. Now, whenever you run this request, data with new spent dates will append to the end of your existing data.
    harvest-append

Part 9: API Documentation

Official API documentation: https://help.getharvest.com/api-v2/

Appendix: Connect with a Personal Access Token

This section is provided as a free alternative to the method described above. Instead of clicking Harvest in the Connections manager, you will retrieve your personal access token yourself. Once you have it, enter it into the Headers section. Since you’re manually including an API token, leave OAuth2 authentication set to None.
  1. Sign into Harvest and navigate to their Developer Tools page (https://id.getharvest.com/developers)
  2. Click “Create New Personal Access Token”
    harvest-img10
  3. Give it a name and click “Create Personal Access Token”. You can name it anything, but we’ll call it ‘Google Sheets’ here.
    harvest-img11
  4. 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.
    harvest-img12
  5. 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:
    harvest-img13
Harvest-Account-IdYOUR_ACCOUNT_ID
AuthorizationBearer YOUR_TOKEN
User-AgentYOUR_TOKEN_NAME (YOUR_EMAIL)
Previous Import Google Search Console Data to Sheets
Next Import HubSpot Data to Google Sheets

26 thoughts on “Import Harvest Data to Google Sheets”

  1. Great help, pulls data in! Is it possible to set a data range of the data pulled in however, i’m unclear how much data this is pulling

    Reply
    • Most of Harvest’s API responses sort by recency (e.g. the ‘spent_date’ or ‘created_at’ fields) and are limited to 100 records. You can see the specific default sort field in the documentation, but generally this means that if you run a Harvest API query without any parameters, it will return most recent 100 records. If you wanted to get data for, say, February, you’d add parameters like https://api.harvestapp.com/v2/time_entries?from=2019-02-01&to=2019-02-28

      Reply
      • Hi Ana,
        is it planned to expand the record limit in the near future? with only 100 records we’re very limited in all requests we do. 🙁

  2. I’m getting a “Failed to run request” error when coping the above (but with my token info).
    Can you explain what “Bearer” in the Authorization key is for?

    Reply
    • Hi Shawn, the string “Bearer” is required by Harvest. More generally, “Bearer” authentication is an HTTP authentication scheme. If you’re still having trouble feel free to email over a screenshot and I’ll take a look.

      Reply
  3. Hello my data got pulled in, but it didn’t pull in Header information to the Gsheet, and some fields that are text , are showing as numbers. Can you help me ?

    Reply
    • Can you please click the ‘Output Options’ button and check what mode you’re in? Overwrite mode will print out headers, while Append mode won’t (info).
      As for fields showing up as numbers instead of text, formats are automatically assigned by Google based on its best guess of what the data is. If it has guessed incorrectly, please try changing the format using Sheets built-in format functions. You can also create a new sheet where you assign the correct data formats to each column, and then populate those columns by querying your API data sheet (e.g. =QUERY(Harvest!A:Z, “select A, B,C”)

      Reply
  4. Hi.
    I can’t use a token at harvest because my client prefer the authentication by using email&password.

    client = harvest.Harvest(f”https://{account}.harvestapp.com”, email, password)
    client.who_am_i

    My client wants to make an arbitrary query to the harvest API to get a report on how the user spent their time.
    But in that case, I don’t find any solution in harvest API v2 documentation.
    Please help me with this problem.

    Kind regards.
    Mark.

    Reply
    • Sorry, I don’t think I can help you here, since as you found in the documentation, Harvest V2 API only provides 2 methods of authentication, and neither involves email & password. However you can check the V1 version of their API. It uses Basic Authentication, which basically means encoding your email address and password to base64 and adding it to a header. Maybe that works for you? (V1 documentation).

      Reply
  5. Hello,

    I created a new tab/sheet and when the sheet is selected I click ‘Set’ and I get

    ScriptError: Authorization is required to perform that action.

    Do you know what I need to fix here? I have written out the three headers according to your format. I don’t see any issues there or with the API URL.

    Any ideas? I appreciate your help.

    Reply
      • Hello Ana, Thank you for the prompt reply. What I’m trying to do is get the Time Entries with the Tasks name “Admin”. Did try to add the parameters after the URL name=Admin and still it doesn’t work. Can youp please help?

      • If you’re looking to filter the time_entries endpoint, you need to use the task_id parameter, like this: https://api.harvestapp.com/v2/time_entries?task_id=YOUR_TASK_ID, where you substitute in your own task ID. If you don’t know your task ID, you can find it by querying the endpoint https://api.harvestapp.com/v2/tasks/.

  6. Any idea how to get a custom column to stay when the API runs? For example, Harvest has a date column but in order to keep my pivots flowing I need a month column. I made one off to the side but it disappears whenever the API runs. Thoughts?

    Reply
    • Hi John, I suggest using a Sheets function like QUERY() to pull all your data into a second sheet, and then creating any custom columns and calculations in that second sheet. Alternately you can use JMESPath filtering, which allows you to fix your columns in place from the start.
      Update: you can now use the visual field editor to fix fields in place. You could also choose a starting column for your column and put any calculations on the left side where they won’t get overwritten.

      Reply
  7. Hi Ana,

    I’ve duplicated last year’s report to a new sheet for 2022, and I’ve including the same setup I had for the API connector with Harvest.

    When I run the report, I can only see times logged in the past two days rather than the whole month.
    https://api.harvestapp.com/v2/time_entries?from=2022-01-01&to=2022-01-31

    Any ideas on how to resolve this?

    Reply
  8. Hi Ana, I am trying to get active projects returned for certain clients using multiple filters but it is not working:
    https://api.harvestapp.com/v2/projects?is_active=true&client_id=8208457&client_id=11692539&client_id=10828140&client_id=4089177

    What am I doing wrong?
    Thanks,
    LC

    Reply
    • My reading of their documentation is that you can only include a single client ID (it says client_id: Only return projects belonging to the client with the given ID). If you’d like to get multiple client IDs, I’d set up a multi-query request. Just list out your URLs one after the other, like this, and API Connector will run through them from top to bottom:
      https://api.harvestapp.com/v2/projects?is_active=true&client_id=8208457
      https://api.harvestapp.com/v2/projects?is_active=true&client_id=11692539
      https://api.harvestapp.com/v2/projects?is_active=true&client_id=10828140
      https://api.harvestapp.com/v2/projects?is_active=true&client_id=4089177

      Reply

Leave a Comment

Table of Contents