Application Programming Interface

The HabitRPG Application Programming Interface
The HabitRPG API is a service which allows programmers to create programs which interface with HabitRPG. With the user credentials on the API Options tab, third-party applications can synchronize or integrate with HabitRPG, gaining limited access to display and potentially change user and system details. Currently in its second revision, any access to the v1 API has been deprecated.

Creating Programs that interface with HabitRPG
Programmers can use the API to write tools or applications. The API is intended for two distinct audiences:
 * 1) Extensions and scripts
 * 2) Full fledged applications

Extensions and Scripts
Extensions and scripts can use Habit's up/down scoring for individual tasks. An example of this in action is the Chrome Extension, which up-scores you for visiting productive websites, and down-scores you for visiting procrastination websites. Other examples currently in use are Pomodoro, Anki, and Github scripts - which up-score you for good behavior and down-score you for bad behavior.

For extensions and scripts, HabitRPG has a simple API for up-scoring and down-scoring third party Habits. Programmers should issue an HTTP POST to: /api/v2/user/tasks/{id}/{direction} For example, this applescript command coupled with a timer can record a + on a habit at regular intervals. Replace xxxxx with your User ID and API-key. Change 'productivity' to whatever you want to call your habit. do shell script "curl -X POST --compressed -H 'Content-Type:application/json' -H 'x-api-user: xxxxx ' -H 'x-api-key: xxxxx ' https://habitrpg.com/api/v2/user/tasks/productivity/up"
 * {id} is a unique identifier for a task consisting of lowercase letters. Try to make it something common, like 'productivity' or 'fitness' - because other services may piggy-back off your task. For example, the Chrome extension down-scores a 'productivity' task when you visit vice websites (reddit, 9gag, etc). However, Pomodoro up-scores 'productivity' when you complete a task. So the two services share a single task to score your overall productivity. If the task doesn't yet exist, it is created the first time you POST to this URL.
 * {direction} is 'up' or 'down'
 * A POST body consisting of the API token is required

Full-fledged applications
The second API consumers are full-fledged applications, which need read / write access to the entire user document. An example of this would be the Mobile Apps or Desktop applications.