npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

habitrpg-api

v1.0.2

Published

A Javascript wrapper for the HabitRPG api.

Downloads

12

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.