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

chiefpay

v2.0.0

Published

The official TypeScript SDK for interacting with the ChiefPay payment system. It supports both REST API requests and real-time updates via WebSockets.

Readme

ChiefPay SDK

The official TypeScript SDK for interacting with the ChiefPay payment system. It supports both REST API requests and real-time updates via WebSockets.

Installation

npm install chiefpay

Usage

Initialization & Connection

import { ChiefPayClient, isInvoiceNotification, ChiefPayError } from "chiefpay";

const client = new ChiefPayClient({
  apiKey: "5456ae39-a9b3-4607-8ed9-8cc4fc67e918",
  // baseURL: "https://api.chiefpay.org" // Optional
});

client.on("error", err => console.error("SDK Error:", err));
client.on("connected", () => console.log("Socket connected"));

// Connect to socket.io for real-time updates
client.connect();

Real-time Rates & Notifications

// Listen for exchange rate updates
client.on("rates", rates => {
  console.log("Current rates:", rates); // e.g., [{"name": "BNB", "rate": "624.48"}]
});

// Handle incoming notifications (Invoices and Transactions)
client.on("notification", async (notification) => {
  // If your code throws an error here, the notification is NOT acknowledged.
  // The server will retry sending it ONLY upon your next socket reconnection.
  if (isInvoiceNotification(notification)) {
    console.log("Invoice status update:", notification.invoice.status);
  } else {
    console.log("New transaction received:", notification.transaction.txid);
  }
});

API Methods

Invoices

  • createInvoice(request): Generates a new payment request. If amount or chainToken are omitted, the payer can select them on the hosted payment page.
  • getInvoice(invoiceId): Retrieves the current status and details of a specific invoice.
  • patchInvoice(invoiceId, request): Used for specifying or refining invoice details. It only allows setting fields that were not provided during creation (e.g., if you created an invoice without an amount, you can set it here). Attempting to overwrite existing fields will result in an error.
  • prolongInvoice(invoiceId): Extends the expiration time of the invoice. This can be called only once; subsequent calls return an ALREADY_EXISTS error.
  • cancelInvoice(invoiceId): Manually cancels the invoice.
  • invoiceHistory(query): Returns a paginated list of invoices. Use fromDate and toDate for filtering.

Static Wallets

  • createWallet(request): Creates a permanent wallet (static address) linked to your orderId. Useful for user balance top-ups.
  • getWallet(walletId): Returns the wallet details and the list of generated blockchain addresses.
  • transactionsHistory(query): Returns a paginated list of all incoming blockchain transactions.

Rates & Payment methods

  • updateRates(): Force-refreshes the token rates via HTTP.
  • getPaymentMethods(): Get a list of payment methods.

Invoice Statuses

| Status | Description | | --- | --- | | WAITING_SELECTION | Payer needs to select a currency/network on the payment page. | | WAITING_PAYMENT | Invoice is active, waiting for a transaction in the blockchain. | | COMPLETE | Payment received and confirmed within the specified accuracy. | | EXPIRED | Payment window has closed. | | CANCELED | Invoice was manually or programmatically canceled. | | OVER_PAID | Received more funds than the requested amount. | | UNDER_PAID | Received some funds, but less than the required amount. |


Error Handling

The SDK provides a robust error handling mechanism. API-specific errors use the ChiefPayError class, while network or parsing issues use standard Error.

try {
  const invoice = await client.createInvoice({
    orderId: "unique_order_id",
    amount: "10.5",
    currency: "USD"
  });
} catch (e) {
  if (e instanceof ChiefPayError) {
    // API-side errors
    switch (e.code) {
      case "INVALID_ARGUMENT": console.error("Validation failed:", e.message); break;
      case "UNAUTHENTICATED": console.error("Invalid API Key"); break;
      case "PERMISSION_DENIED": console.error("Insufficient permissions"); break;
      case "ALREADY_EXISTS": console.error("This orderId is already taken"); break;
      case "NOT_FOUND": console.error("Resource not found"); break;
      case "INTERNAL": console.error("ChiefPay server error"); break;
      default: console.error("API Error:", e.code, e.message);
    }
  } else {
    // Network errors, timeouts, or JSON parsing issues
    console.error("Non-API error:", e);
  }
}

Note on Rate Limiting: If you receive a 429 Too Many Requests response, the SDK will automatically retry the request up to 3 times, respecting the retry-after-ms header provided by the server.