Important notice about the migration from API v2 to v3

The Overview of Changes in Version 3 of the API post, in the section about tasks IDs, stated this:

Because of the requirement for unique task IDs across all users, some of your task IDs may have changed. If your task ID was a valid UUID and was unique across all players, the ID remained the same. Otherwise, a newly generated unique ID replaced the original ID of the task.

We've just realized that this isn't correct and that instead all the tasks IDs used in API v3 have been randomly generated from scratch. This means that apps or extensions relying on tasks IDs remaining the same between API v2 and v3 will have to prepare for IDs to change between API v2 and v3.

So in most cases, the easiest way to update the ids is to fetch all the tasks using the GET https://habitica.com/api/v3/tasks/user route, loop over the array of tasks, check if a task has a _legacyId, and if it does, replace the stored id in your integration with the id field from the task.

Here's an example for how to do this in Node:

var request = require('superagent');  
var YOUR_USER_ID = 'Your User Id Goes Here';  
var YOUR_API_TOKEN = 'Your API Token Goes Here';

request.get('https://habitica.com/api/v3/tasks/user')  
  .set('x-api-user', YOUR_USER_ID)
  .set('x-api-key', YOUR_API_TOKEN)
  .end(function (error, result) {
    if (error) {
      console.error('An error occurred with the request');
      console.error(error);
      return;
    }

    var tasks = result.body.data;

    var tasksToUpdate = tasks.filter(function (task) {
      return task._legacyId;
    });

    tasksToUpdate.map(replaceId);
  });

function replaceId (task) {  
  var oldId = task._legacyId;
  var newId = task.id;

  // check if old id exists in stored ids
  // if it does, replace with new id
}

Due to this discovery we've decided to keep API v2 active until July 30th instead of the planned July 15th to ease the transition from v2 to v3.

We're sorry about any problem this may have caused.