A very thin wrapper for the Habitica API
npm install habitica --save
This package is intentionally light and unopinionated. It should be used in conjunction with Habitica's API documentation.
The first thing you need to do is instantiate your client. All the configuration properties are optional and can be set later.
var Habitica = ;var api =id: 'your-habitica.com-user-id'apiToken: 'your-habitica.com-api-token'endpoint: '' // defaults toplatform: 'Your-Integration-Name' // defaults to Habitica-Node;
localLogin methods will set the User Id and API token automatically.
If your integration prompts the user to enter their credentials, you can use the
There are four main methods to make requests to the API.
del. Each corresponds to one of the main HTTP verbs.
get takes an optional second argument that is an object that gets converted to a query string. The rest have an optional second argument that is the post body and a third optional argument that will be converted to a query string.
Each method returns a promise which resolves the raw data back from the API. The data will reside on the data property.
For full documentation with examples visit the docs site.
The documentation is generated automatically using JSDoc.
To run all the tests:
$ npm t
The bulk of the tests are integration tets that expect a Habitica dev instance to be running.
A mongodb instance must be running already in order to run the tests locally.
By default, the test infrastructure assumes that the repo for Habitica is '../../habitica', relative to the test directory. You may pass in your own path by exporting the environmental variable
$ export PATH_TO_HABITICA='../../some/other/path';
By default, the app will be served on port 3321. This can be configured with the environmental variable
$ export HABITICA_PORT=3001;
By default, the mongodb uri is 'mongodb://localhost/habitica-node-test'. You can configure this variable with the environmental variable
$ export HABITICA_DB_URI='mongodb://localhost/some-other-db';
This module requires the
Promise object to function. If you are using this module in a context without
Promises (such as Browserifying for IE9), you will need to polyfill them.
Supports Node >= 4