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 🙏

© 2025 – Pkg Stats / Ryan Hefner

codebase-npm

v1.0.3

Published

NPM Package that interacts with CodebaseHQ

Readme

codebase-npm

A NodeJS library for the CodebaseHQ API

Note

This library creates objects for users, projects, tickets etc. When you make a query to retrieve tickets (this is just an example, it can apply to other classes too) it will attempt to look up the users and link the ticket assignee/reporter with the user. If you haven't already retrieved users then your ticket will have no assignee or reporter assigned to it. Because of this, the best steps to take are:

  • retrieve users
  • retrieve projects
  • retrieve tickets for the project
  • retrieve time sessions for the project

Instructions for each of these steps can be found below.

There is also an examples project with some demos to help understand the code and how it functions. This can be found here.

Usage

Connecting to the API

In order to connect to and query the codebase API you need to create a CodebaseHQAccount object

import { codebase } from 'codebase-npm';
let codebaseConnection = new codebase(apiUser, apiKey, apiHostname);

Retrieving All Users

Users are pulled at the account level

let users = await codebaseConnection.users();

This returns a UserCollection - searching should be done on the collection, the class has a few helper methods for this. This is also built from the library 'collectionsjs' which can be found here.

Retrieving Projects

Projects can be pulled as a whole for the account, or individually by permalink. Projects are populated with all of their categories, priorities, statuses and types.

Retrieving All Projects

Projects are also pulled at the account level

let projects = await codebaseConnection.projects();

This returns a ProjectCollection - searching should be done on the collection, the class has a few helper methods for this again this is extended from the CollectionsJS node module.

Retrieving Individual Projects

You can pull an individual project by the permalink (note the method name is singular)

let project = await codebaseConnection.project('project-permalink');

This returns a Project model - not a collection

Retrieving Tickets for a Project

Tickets can only be retrieved if you have a Project object.

await codebaseConnection.tickets(project, pageNo);

project.getTickets();

The tickets method returns a boolean indicating whether there are further results (as the results are paginated). The tickets themselves are added to a TicketCollection in the project. As always, searching should be done on the collection, the class has a few helper methods for this

Pagination

Tickets are paginated, with 20 per page. You can write a simple loop to pull all tickets for the project

let pageNo = 1;
let moreResultsToRetrieve = true;

while (moreResultsToRetrieve) {
    moreResultsToRetrieve = await codebaseConnection.tickets(project, pageNo);
    pageNo++;
}

Retrieving Time Sessions for a Project

Time Sessions can only be retrieved if you have a Project object. You must also pass through a period to retrieve the times for, this can be a day/week/month or all - classes exist for each one.

// can be All|Day|Week|Month
import {All, Day, Week, Month} from 'codebase'

await codebaseConnection.times(project, new Week());

Time sessions will be associated with the project, the ticket and the user if you have populated those collections.

// times for the project
project.getTimeSessions();

// times associated to a user
user.getTimeSessions();

// times associated to a ticket
ticket.getTimeSessions();