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

stackcoin

v0.2.1

Published

TypeScript library for the StackCoin API

Readme

stackcoin-typescript

TypeScript library for the StackCoin API. Provides a typed REST client and a WebSocket gateway for real-time events.

Install

npm install stackcoin

Requires Node 21+. Types are generated from the StackCoin OpenAPI spec via openapi-typescript.

Quick start

import { Client } from "stackcoin";

const client = new Client({ token: "..." });

const me = await client.getMe();
console.log(`${me.username}: ${me.balance} STK`);

const events = await client.getEvents();
for (const event of events) {
  console.log(`[${event.type}] ${event.data}`);
}

Gateway (real-time events)

import { Client, Gateway } from "stackcoin";
import type { TransferCompletedEvent, RequestAcceptedEvent } from "stackcoin";

const gateway = new Gateway({ token: "..." });

gateway.on("transfer.completed", (event) => {
  const e = event as TransferCompletedEvent;
  console.log(`Transfer of ${e.data.amount} STK from #${e.data.from_id} to #${e.data.to_id}`);
});

gateway.on("request.accepted", (event) => {
  const e = event as RequestAcceptedEvent;
  console.log(`Request #${e.data.request_id} accepted`);
});

await gateway.connect();

Catching up on missed events

If your bot persists its cursor position and reconnects with a lastEventId, the server replays up to 100 missed events. If more than 100 were missed, the join is rejected -- pass a client so the Gateway can automatically catch up via the REST API. Without a client, a TooManyMissedEventsError is raised.

import { Client, Gateway } from "stackcoin";
import type { TransferCompletedEvent } from "stackcoin";

const client = new Client({ token: "..." });

const gateway = new Gateway({
  token: "...",
  client,
  lastEventId: savedCursor,
  onEventId: (id) => saveCursor(id),
});

gateway.on("transfer.completed", (event) => {
  const e = event as TransferCompletedEvent;
  // ...
});

await gateway.connect();

Examples

  • examples/basic-usage.ts -- REST client basics (balance, users, transactions)
  • examples/gateway.ts -- WebSocket gateway with live event handlers

Testing

Tests for this library live in the main StackCoin/StackCoin repository as end-to-end tests that boot a real StackCoin server:

cd /path/to/StackCoin/test/e2e/ts
pnpm install
pnpm test

The E2E suite covers the REST client (Client) and WebSocket gateway (Gateway) against a live server. Tests are run with vitest and include transfers, payment requests, event pagination, idempotency, and real-time event delivery over WebSocket.

Development

Types are generated from the StackCoin OpenAPI spec using openapi-typescript:

just generate

This regenerates src/schema.d.ts from openapi.json.