Using the Harvest API

Using the Harvest API

by 

| October 19, 2021 | in

Anyone who does consulting is keenly aware of the importance of time tracking.

Harvest is an excellent tool for logging time for projects. It’s the system we use here at Don’t Panic Labs, and we’ve found it to be both low friction and highly valuable.

But there may be times when you want to use this data outside of your tracking system. Maybe you want to see which people are working on many projects and which people are working on one project at a time.

Whatever your reason, it is nice to pull the data from your time tracking system.

With Harvest, the first step would be creating a Personal Access Token. You can acquire these tokens by going to https://id.getharvest.com/developers and clicking “Create New Personal Access Token”.

Create New Personal Access Token

Once you have a token, I recommend you do a quick curl check to ensure it is working. Harvest will provide you with this in the “Testing Your Token” section on the developers page. (https://id.getharvest.com/developers)

Now we need to grab some time data, and Harvest has good information on what you can pull from the time entries.

Calling and getting the time data doesn’t require much from a code perspective. The code below will go out and get a page of harvest records (for 2021).

The code above will retrieve 100 entries at a time and loop until it reaches the end. You will need to perform the loop because the Harvest API limits us to retrieving only 100 entries at a time.

The code above does assume you have the contract in C# that matches the JSON returned by the API. The code below will match what the API is returning.

Getting data from Harvest isn’t difficult; they have a good API. If you are trying to dive deeper and pull some data out of Harvest, I hope this post helps.


Related posts