Developers welcome! The mite.api is looking forward to your precious hacking. Have a look at the detailed documentation to kick-start your coding.

Please note: The tracker can only be shown, started and stopped for the authenticated user. Every user has only one tracker; hence it is impossible to run two trackers per user at the same time.

Show tracker

Returns the time tracker for the authenticated user.

GET /tracker.xml
GET /tracker.json

If the time tracker is running:

Status: 200 OK
{
  "tracker": {
    "tracking_time_entry": {
      "id": 36135321,
      "minutes": 247,
      "since": "2015-10-15T17:05:04+02:00"
    }
  }
}
Status: 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<tracker>
   <tracking-time-entry>
      <id type="integer">247</id>
      <minutes type="integer">36135321</minutes>
      <since type="datetime">2015-10-15T17:05:04+02:00</since>
   </tracking-time-entry>
</tracker>

If the time tracker is not running you will retrieve an empty response.

Status: 200 OK
{
  "tracker": {}
}
Status: 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<tracker></tracker>

Start tracker

Start the tracker for the time entry given by the id.

PATCH /tracker/:id.xml
PATCH /tracker/:id.json

Request

Status: 200 OK
{
  "tracker": {
    "tracking_time_entry": {
      "id": 36135322,
      "minutes": 0,
      "since": "2015-10-15T17:33:52+02:00"
    }
  }
}
Status: 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<tracker>
   <tracking-time-entry>
      <id type="integer">36135322</id>
      <minutes type="integer">0</minutes>
      <since type="datetime">2015-10-15T17:33:52+02:00</since>
   </tracking-time-entry>
</tracker>

The attribute minutes contains the minutes since the tracker is running plus the minutes already present on the time entry. Thus the value of minutes can be higher than zero even when starting it for the first time.

If the time tracker is already running on the time entry, we will not start it again. Instead we just return its current state.

If the time tracker is running on another time entry it will be stopped there. Remember: Only one time tracker per user can run at a given time. You will retrieve a response containing the state of the stopped entry alongside the now running tracker:

Status: 200 OK
{
  "tracker": {
    "tracking_time_entry": {
      "id": 36135322,
      "minutes": 0,
      "since": "2015-10-15T17:33:52+02:00"
    },
   "stopped_time_entry": {
      "id": 36134329,
      "minutes": 46
    }
  }
}
Status: 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<tracker>
   <tracking-time-entry>
      <id type="integer">36135322</id>
      <minutes type="integer">0</minutes>
      <since type="datetime">2015-10-15T17:33:52+02:00</since>
   </tracking-time-entry>
   <stopped-time-entry>
      <minutes type="integer">46</minutes>
      <id type="integer">36134329</id>
   </stopped-time-entry>
</tracker>

Stop tracker

Stops the time tracker on the time entry with the given id and returns its last state.

DELETE /tracker/:id.xml
DELETE /tracker/:id.json

Request

Status: 200 OK
{
  "tracker": {
   "stopped_time_entry": {
      "id": 36135322,
      "minutes": 4
    }
  }
}
Status: 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<tracker>
   <stopped-time-entry>
      <minutes type="integer">4</minutes>
      <id type="integer">36135322</id>
   </stopped-time-entry>
</tracker>

Stopping the tracker is by design idempotent and as a result of that can be performed twice, too late or even with the id of a time entry which the tracker was never started on.