Registry / gaming / ps2census

ps2census

JSON →
library4.9.1jsnpmunverified

Client library for interacting with the Planetside 2 Census API and Event Stream websocket, written in TypeScript. Current stable version is 4.9.1, actively maintained with regular releases. Key differentiators: unified interface for both Event Stream and REST API, built-in reconnection logic, subscription management, and support for community endpoints like Nanite Systems ESS. Requires Node.js 14+ and a DBG Census API Service ID. Optional peer dependencies bufferutil and utf-8-validate for performance.

npm install ps2census
INSTALL
IMPORT
SIG · PS2CENSUS
P
ps2census
gamingjavascriptv4.9.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CensusClient
import { CensusClient } from 'ps2census'
const CensusClient = require('ps2census').CensusClient
ESM import for TypeScript projects; CommonJS require also works but must destructure.
Rest
import { Rest } from 'ps2census'
const Rest = require('ps2census').Rest
Rest is a namespace containing Client and other classes.
Subscription
import type { Subscription } from 'ps2census'
import { Subscription } from 'ps2census'
Subscription is a type export; use import type for TypeScript.

Sets up a CensusClient to connect to the PS2 Event Stream, subscribing to MetagameEvents on world 10.

const { CensusClient } = require('ps2census'); const client = new CensusClient('example', 'ps2', { streamManager: { subscription: { worlds: ['10'], eventNames: ['MetagameEvent'], }, }, }); client.on('ps2Event', event => { console.log('Event received:', event); }); client.on('ready', () => { console.log('Client ready'); }); client.on('error', error => { console.error('Error:', error); }); client.watch();
Debug
Known issues
deprecatedThe constructor option 'streamManager.endpoint' has been replaced by 'streamManager.url' in v4.0.
fix
Use 'url' instead of 'endpoint' in the streamManager configuration.
affects: >=4.0.0
breakingv4.0 removed support for Node.js <14. The engine requirement changed from >=10 to >=14.
fix
Upgrade to Node.js 14 or later.
affects: >=4.0.0 <5.0.0
breakingThe 'Rest.Client' constructor no longer accepts a second argument for 'serviceId' as a string; it must be passed in an options object.
fix
Use 'new Rest.Client('ps2', { serviceId: 'example' })' instead of passing serviceId as second string.
affects: >=4.0.0 <5.0.0
gotchaEvent names in event listeners are camelCase starting with a lowercase letter (e.g., 'facilityControl'), while the Census API uses PascalCase. This mismatch causes missed events if using the wrong casing.
fix
Use lowercased first letter: 'facilityControl' not 'FacilityControl'.
affects: *
deprecatedThe 'client.on('duplicate', ...)' event is deprecated in v4.5.0. Use the 'duplicateFilter' option to handle duplicates.
fix
Remove the 'duplicate' event listener and enable duplicate filtering in the client configuration.
affects: >=4.5.0
Errors
Common errors & fixes
Error: Service ID is required
Missing or invalid service ID passed to CensusClient constructor.
fix
Provide a valid DBG Census API Service ID as the first argument: new CensusClient('s:example', 'ps2');
Error: Cannot find module 'bufferutil'
Bufferutil is an optional peer dependency but not installed.
fix
Install optional dependencies: npm install --save-optional bufferutil utf-8-validate
TypeError: client.watch is not a function
CommonJS require syntax used incorrectly; CensusClient imported as default instead of named export.
fix
Use destructured require: const { CensusClient } = require('ps2census');
Unhandled 'error' event: Error: WebSocket connection to 'wss://push.nanite-systems.net/streaming' failed
Network issue or the Nanite Systems endpoint is unreachable.
fix
Check network connectivity and verify the endpoint URL. Fall back to the official Census endpoint if needed.
Upgrade
Version history
4.9.1latest on npm
Audit
Dependencies
bufferutiloptionalOptional peer dependency for WebSocket performance
utf-8-validateoptionalOptional peer dependency for WebSocket performance
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
ps2census — npm install ps2census · libregistry