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 🙏

© 2026 – Pkg Stats / Ryan Hefner

botshub

v1.1.0

Published

BotsHub SDK for fetching Discord bot metadata and syncing bot stats.

Readme

BotsHub JavaScript SDK

The BotsHub SDK connects a Discord bot to the BotsHub platform. It can read bot metadata, collect aggregate statistics, publish those statistics to BotsHub, and receive platform events such as votes and reviews.

The SDK is designed for server-side Node.js applications and requires Node.js 18 or newer.

Install

npm install botshub

Create a client

Create the client in your bot's server process. Load all credentials from a secure server-side environment or secret manager; never include them in source control, browser code, logs, or public configuration.

import BotsHub from 'botshub';

const hub = new BotsHub({
  appId: process.env.DISCORD_APP_ID,
  botToken: process.env.DISCORD_BOT_TOKEN,
  secret: process.env.BOTSHUB_SECRET,
});

Use with discord.js

Attach an authenticated discord.js client to read information from its local cache without making additional Discord API requests.

hub.attach(discordClient);

const info = await hub.getBotInfo();
const guilds = await hub.getGuilds();
const stats = await hub.getStats();

await hub.postStats();

To publish aggregate statistics periodically:

hub.startAutoPost();

// Stop timers and close connections during application shutdown.
hub.destroy();

Standalone usage

The SDK can use the Discord REST API when a discord.js client is not attached.

const info = await hub.getBotInfo();
const guilds = await hub.getGuilds({ detailed: true });
const commands = await hub.getCommands();

Platform events

BotsHub can deliver application-scoped events through its real-time gateway. Use the SDK credentials generated in the BotsHub owner dashboard and keep the private credential server-side.

import BotsHub, { Event } from 'botshub';

const events = new BotsHub({
  appId: process.env.DISCORD_APP_ID,
  secretKey: process.env.BOTSHUB_SECRET_KEY,
});

events.subscribe(Event.EventVote, async (vote) => {
  await handleVote(vote);
});

events.subscribe(Event.EventReview, async (review) => {
  await handleReview(review);
});

await events.connect();

The gateway automatically authenticates the client, maintains heartbeats, reconnects after temporary failures, and rejects events outside the configured application scope.

Available operations

  • attach(client) — use an existing discord.js client.
  • getBotInfo() — read basic bot and application metadata.
  • getGuilds(options) — read guild counts or detailed guild information.
  • getCommands() — read registered application commands.
  • getStats() — collect aggregate bot statistics.
  • postStats(extra) — send aggregate statistics to BotsHub.
  • startAutoPost(intervalMs) — periodically send statistics.
  • connect() and disconnect() — manage the real-time event connection.
  • subscribe(event, listener) — receive a platform event.
  • ping() — check Discord and BotsHub connectivity.
  • destroy() — release timers, listeners, cache, and connections.

Security

  • Run the SDK only in a trusted server environment.
  • Store credentials in environment variables or a dedicated secret manager.
  • Never send bot tokens, private keys, user data, or credentials as event data.
  • Rotate a credential from the BotsHub dashboard if it may have been exposed.
  • Grant the application access only to the secrets it needs.