ha

habitrpg-api

NPM module that wraps the habitrpg-api in an easy to use format.

Showing:

Popularity

Downloads/wk

11

GitHub Stars

4

Maintenance

Last Commit

5yrs ago

Contributors

3

Package

Dependencies

2

Size (min+gzip)

13.4KB

License

GPL-3.0-or-later

Type Definitions

Tree-Shakeable

No?

Categories

Readme

habitrpg-api

Build Status

NPM module that wraps the habitrpg-api in an easy to use format.

Table of Contents

Initializtion

var habitapi = require('habit-rpg');
new habitapi(userId, apiKey);

Alternatively, to point at a custom server:

var habitapi = require('habit-rpg');
new habitapi(userId, apiKey, apiUrl);

User

GET /user

Gets the full user object

.getUser(function(response, error){})

Tasks

POST /user/tasks

Posts a new task to create

var task = {
    text: 'New Task',
    type: 'todo'
}
.createTask(task, function(response, error){})

GET /user/tasks/:id

Gets an individual task

.getTask(id, function(response, error){})

GET /user/tasks

Gets all user tasks

.getTasks(function(response, error){})

PUT /user/tasks/:id

Puts a users task to update

var task = {
    text: "Updated text"
}
.updateTask(id, task, function(response, error){})

POST /user/tasks/:id/:direction

Posts an increase or decrease to a user's task score.

var direction = true // Add to score; false to substract
.updateTaskScore(id, direction, function(response, error){})

DEL /user/tasks/:id

Deletes a task

.deleteTask(id, function(response, error){})

Tags

POST /user/tags

Posts to create a new tag

var tag = {
    name: 'habitrpg-api'
}
.createTag(tag, function(response, error){})

GET /api/tags/:name

This REST Endpoint isn't officially supported by HabitRPG. It get's the entire user object and parses out just the tag based on name.

.getTagByName(name, function(response, error){})

GET /api/tags/:id

This REST Endpoint isn't officially supported by HabitRPG. It get's the entire user object and parses out just the tag.

.getTag(id, function(response, error){})

GET /api/tags

This REST Endpoint isn't officially supported by HabitRPG. It get's the entire user object and parses out just the tags.

.getTags(function(response, error){})

PUT /user/tags/:id

Puts a tag to update it

var tag = {
    name: 'update-tag'
}
.updateTag(id, tag, function(response, error){})

DEL /user/tags/:id

Deletes a tag

.deleteTag(id, function(response, error){})

Groups

GET /groups

Gets a list of all groups

.getGroups(function(response, error){})

GET /groups?type=

Gets a list of all groups of a certain type

.getGroupsByType("comma,seperated,string", function(response, error){})

GET /groups/:id

Gets an individual group

.getGroup(id, function(response, error){})

Miscellaneous

GET /api-docs

Currently this doesn't return anything, but it is documented.

.getApiDocs(function(response, error){})

GET /status

Get the API server status to determine if it is up

.getStatus(function(response, error){})

GET /content

Gets all available content objects

.getContent(function(response, error){})

GET /export/history

Gets the user history for export

.getHisory(function(response, error){})

Testing

Clone the HabitRPG Repo and follow the setup instructions.

In the habitrpg-api repo, copy the config.example.js file to config.js and fill in the userId and apiKey in the apiSettings object for your user on your local copy of HabitRPG.

cp config.example.js config.js
var apiSettings = {
  apiKey: 'ReplaceThisWithYourAPIToken',
  userId: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
};

Start up the local copy of HabitRPG. And run this command:

gulp watch

Adjust the lib and test files as needed.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100