Free Automated Time Tracking

There are quite a few reasons for why you should be tracking the time you’ve spent on your projects, just read through one of the many websites that sell time tracking tools. If you are tech savvy, you might actually prefer having access to an easy to use and free API that allows you to do just that.

Usecase

At the end of this tutorial, you will be able to automatically keep track of how much time you’ve spent at your office (or wherever), without ever having to interact with a time tracking tool.

If you convince your team to also follow this tutorial, you could analyse who’s at the office during which time of the day and for how long, or quickly see who’s currently there.

The Tracking API

Luckily, there’s a free time tracking API on GitHub that you can use for automated time tracking. It’s a simple JSON API hosted on the Google App Engine, providing endpoints for our use case.

The API can handle 3 basic objects:

  • Users, representing the one who is using the API (e.g. you)
  • Topics, representing whatever you want to track (e.g. a project or location)
  • Actions, representing tracking events (e.g. starting or stopping to work)

Setup

First of all, you’ll need to create a user and a topic, so that your activities can be assigned to you and your project. Fire the following web requests to create a new user called “John Doe” and a new topic named “Work”:

http://placetracking.appspot.com/api/users/add/?name=John%20Doe
http://placetracking.appspot.com/api/topics/add/?name=Work

Each of these requests will return a JSON representation of the object you just created. Make sure that you save these, as you will need the ids of these objects for tracking. And that’s it, your good to go and may start tracking now!

Add actions

To actually track something, simply call the following endpoint:

http://placetracking.appspot.com/api/actions/add/?name=start&userId=123&topicId=456

This time, you’ll need to replace “123” and “456” with your user id and topic id (the ones you created during the setup). The request above would create an action named “start”, you would want to fire it each time you start working on your project. In order to let the API know that you stopped working on your project, simply fire:

http://placetracking.appspot.com/api/actions/add/?name=stop&userId=123&topicId=456

Keep in mind that you should always use the same two actions if you want to get any meaningful results later. Actions that make sense could be:

  • start and stop
  • pause and resume
  • arrive and leave

If you are working with a team, make sure that everyone uses the same topic id.

Automate using IFTTT

Of course you don’t want to manually call this API every time. You can automatically trigger actions using IFTTT, for example when you connect to your office WiFi network (see example recipes).

Let’s say you want to automatically add an action to the API whenever you arrive at your office location:

  1. Create a new recipe
  2. Create a trigger

    • Select the Android / iOS Location channel
    • Select the You enter an area trigger
    • Select your office location
  3. Create an action

    • Select the Maker channel
    • Select the Make a web request action
    • Enter the API request for adding an action as URL
    • Set the request Method to GET
  4. Name and save your recipe

Now every time you arrive at your office, IFTTT will automatically add an action to the tracking API. For this to make any sense, you also need to create a recipe that triggers when you leave your office.

If you want to add actions based on your WiFi network, use these pre-configured recipes: Start tracking and Stop tracking.

Analyse what you tracked

After you’ve created some actions, you might want to check what the API recorded for you:

http://placetracking.appspot.com/api/actions/get/?userId=123

You could use the returned data to draw some fancy charts on a website or simply calculate how much time you’ve spent on a project in the last month. If you want to filter the returned actions, you can add some of these parameters to the request:

  • topicId to filter the actions by topic (e.g. “456”)
  • name to filter the actions by name (e.g. “start”)
  • minimumTimestamp to get actions after (e.g. “1468413570000”)
  • maximumTimestamp to get actions before (e.g. “1468417170000”)
  • limit to limit the number of returned actions (e.g. “50”)
  • offset to skip some actions (e.g. “25”)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>