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

@zap.stream/api

v0.1.0

Published

zap.stream API client — live streaming & account management for Nostr

Downloads

77

Readme

@zap.stream/api

TypeScript API client for zap.stream — live streaming & account management for Nostr.

Zero Nostr-library dependencies. Bring your own signer.

Install

bun add @zap.stream/api

Usage

Setup

Create a Signer — the only crypto interface the library needs. Any Nostr library works:

import { NostrStreamProvider, type Signer } from "@zap.stream/api";

const signer: Signer = {
  getPubKey: () => myPublicKey,                        // hex pubkey string
  sign: async (event) => myNostrLib.signEvent(event),  // returns event with id & sig
};

const provider = new NostrStreamProvider("zap.stream", "https://api-core.zap.stream/api/v1", signer);

Getting started — stream key & balance

The main flow: check your balance, get your stream key, top up if needed.

// 1. Check account info
const account = await provider.info();
console.log(`Balance: ${account.balance} sats`);

// Endpoints contain the stream key you push to via RTMP
for (const ep of account.endpoints) {
  console.log(`Endpoint: ${ep.name}`);
  console.log(`  URL: ${ep.url}`);
  console.log(`  Stream key: ${ep.key}`);
  console.log(`  Cost: ${ep.cost.rate} sats/${ep.cost.unit}`);
}

// 2. Top up if balance is low
if (account.balance < 1000) {
  const invoice = await provider.topup(10000); // 10k sats
  // Hand this invoice to the user's wallet
  console.log(`Pay this invoice: ${invoice.pr}`);
}

Withdrawing

const result = await provider.withdraw(bolt11Invoice);
console.log(`Fee: ${result.fee} sats`);
console.log(`Preimage: ${result.preimage}`);

Balance history

const history = await provider.history(0, 20);
for (const item of history.items) {
  console.log(`${new Date(item.created * 1000).toISOString()}: ${item.amount} sats`);
}

Accepting terms of service

New accounts need to accept TOS before streaming:

const account = await provider.info();
if (account.tos && !account.tos.accepted) {
  console.log(`TOS available at: ${account.tos.link}`);
  await provider.acceptTos();
}

Updating stream details

await provider.updateStream({
  title: "Building stuff live",
  summary: "Nostr dev stream",
  tags: ["coding", "nostr"],
  image: "https://example.com/thumbnail.jpg",
});

// Or update from a Nostr live event
import { extractStreamInfo } from "@zap.stream/api";
await provider.updateStreamFromEvent(myLiveEvent, extractStreamInfo);

Real-time metrics (WebSocket)

provider.subscribeToMetrics(streamId, (metrics) => {
  console.log(`Viewers: ${metrics.data?.viewers}`);
  const stats = metrics.data?.endpoint_stats;
  if (stats) {
    for (const ep of Object.values(stats)) {
      console.log(`${ep.name}: ${ep.bitrate} bps`);
    }
  }
});

provider.unsubscribeFromMetrics(streamId);
provider.closeWebSocket();

Wallet integration (NWC)

await provider.configureNwc("nostr+wallet://…");
await provider.removeNwc();

Stream forwarding

await provider.addForward("my-relay", "wss://relay.example.com");
await provider.removeForward(forwardId);

Clips

const clip = await provider.prepareClip(streamId);
const result = await provider.createClip(streamId, clip.id, start, length);

Notifications (Web Push)

const { publicKey } = await provider.getNotificationsInfo();
await provider.subscribeNotifications({ endpoint, key, auth, scope });

Game database

import { GameDatabase } from "@zap.stream/api";

const db = new GameDatabase();
const games = await db.searchGames("minecraft", 10);
const game = await db.getGame("igdb:1234");

Clock sync

import { timeSync } from "@zap.stream/api";

await timeSync.syncClock();   // call once at startup
console.log(timeSync.offset); // ms offset from server

The Signer interface

The only crypto dependency. Two methods:

interface Signer {
  getPubKey(): string | Promise<string>;
  sign(event: NostrEvent): Promise<NostrEvent>;
}

Adapting @snort/system

import { EventPublisher } from "@snort/system";

function adaptPublisher(pub: EventPublisher): Signer {
  return {
    getPubKey: () => pub.pubKey,
    sign: async (event) => {
      return await pub.generic(eb => {
        let builder = eb.kind(event.kind).content(event.content).createdAt(event.created_at);
        for (const tag of event.tags) {
          builder = builder.tag(tag);
        }
        return builder;
      });
    },
  };
}

Dependencies

No Nostr library, no framework, no bundler plugin required.

License

MIT