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

dbgcensus

v1.0.1

Published

A simple way to use the Daybreak Games Census API service

Downloads

27

Readme

dbgcensus

A simple way to use the Daybreak Games Census API service

Table of Contents

Installing

npm install dbgcensus --save

Creating a new query

var CensusQuery = require('dbgcensus').Query;
var query = new CensusQuery('character', 'ps2', 'example')

The dbgcensus.Query constructor accepts a service, optional serviceType, and optional serviceId. If a globalNamespace is not set than that argument becomes required. The acceptable namespaces can be found on the census.daybreakgames.com website. If a serviceId is not provided it defaults to the globalKey if one is set or 'example'.

Returning data from the query

query.get(function (error, data) {
  if (error) {
    // something went wrong!
  }

  //do something with data
});

The data variable represents the data of the collection list. Normally when a query is made with the census API it is returned like:

{
  character_list: [
    {
      'character_id': 1234,
      //etc
    }
  ]
}

However dbgcensus returns just the data so the above becomes:

[
  {
    'character_id': 1234,
    //etc
  }
]

Setting global parameters

var dbgcensus = require('dbgcensus');
dbgcensus.SetGlobalNamespace('ps2:v2');
dbgcensus.SetGlobalServiceKey('example');

Defining a condition

query.where('name.lower').equals('lampjaw');

The following operations and their equivalent syntax is below:

  • equals: =
  • notEquals: =!
  • isLessThan: =<
  • isLessThanOrEquals: =[
  • isGreaterThan: =>
  • isGreaterThanOrEquals: =]
  • startsWith: =^
  • contains: =*

Setting a language

query.setLanguage('en');

No language is set by default so you will receive all localized strings if available.

Show certain fields

query.showFields(['character_id', 'name', 'faction_id']);

Hide certain fields

query.hideFields(['currency', 'times']);

Set a limit for number of rows to return

query.setLimit(10);

Set the starting row

query.setStart(100);

Add a resolve

query.addResolve('world');

or for multiple resolves

query.resolve(['world', 'outfit']);

Join to another service

var worldJoin = query.joinService('characters_world');

Join objects have the following methods:

  • isList(bool)
  • isOuterJoin(bool)
  • showFields(array): See the 'Show certain fields' section above
  • hideFields(array): See the 'Hide certain fields' section above
  • onField(string)
  • toField(string)
  • injectAt(string)
  • where(string): See the 'Defining a condition' section above
  • joinService(string): Returns another join object for sub joining

Tree results on a field

var query = new CensusQuery('vehicle', 'ps2');
var vehicleTree = query.treeField('type_id');

Tree objects have the following methods:

  • isList(bool)
  • groupPrefix(string)
  • startField(string)
  • treeField(string): Returns another tree object for sub grouping

Getting the url of the query

var url = query.toUrl();