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

@chargly/sdk

v0.1.0

Published

Credit-first AI billing SDK for wallets, event metering, top-ups, and Pricing Advisor.

Readme

@chargly/sdk

Credit-first AI billing SDK for Chargly. Meter usage, manage wallets, and create checkouts for credit top-ups.

Install

npm install @chargly/sdk

Quickstart

import { Chargly } from "@chargly/sdk";

const chargly = new Chargly({
  apiKey: process.env.CHARGLY_SECRET_KEY!,
});

// Meter a usage event
await chargly.meterEvent({
  customerId: "user_123",
  event: "image.generate",
  credits: 40,
});

Examples

getWallet

Get wallet balance for a customer.

const wallet = await chargly.getWallet({ customerId: "user_123" });
console.log(wallet.balance, wallet.unit); // 500 "credits"

meterEvent

Record a usage event and deduct credits from the customer's wallet.

const result = await chargly.meterEvent({
  customerId: "user_123",
  event: "image.generate",
  credits: 40,
  metadata: { requestId: "req_abc" },
});
console.log(result.remainingBalance); // 460

createCheckout

Create a Stripe Checkout session for a customer to buy credits.

const checkout = await chargly.createCheckout({
  customerId: "user_123",
  creditPackId: "chargly_2000",
  successUrl: "https://myapp.com/success",
  cancelUrl: "https://myapp.com/cancel",
});
// Redirect user to checkout.checkoutUrl

listCreditPacks

List available credit packs.

const { packs } = await chargly.listCreditPacks();
packs.forEach((pack) => {
  console.log(pack.name, pack.credits, pack.price); // price in cents
});

Error handling

import { Chargly, CharglyError } from "@chargly/sdk";

try {
  await chargly.meterEvent({ customerId: "user_123", event: "chat.reply", credits: 100 });
} catch (err) {
  if (err instanceof CharglyError) {
    console.error(err.message, err.statusCode, err.code);
  }
}

Pricing Advisor

Pricing Advisor helps you decide what AI actions should cost. Recommendations are deterministic, explainable, versioned, and human-approved — you apply or reject; nothing changes without your approval.

Methods

| Method | Description | |--------|-------------| | getPricingRule({ feature }) | Get a pricing rule by feature | | listPricingRecommendations({ feature?, status?, limit? }) | List recommendations, optionally filtered | | getPricingRecommendation({ recommendationId }) | Get a single recommendation | | explainPricingRecommendation({ recommendationId }) | Get detailed explanation (reason, confidence, margin) | | applyPricingRecommendation({ recommendationId }) | Apply recommendation — creates new pricing rule version | | rejectPricingRecommendation({ recommendationId }) | Reject recommendation — preserves audit history |

Example

// List pending recommendations
const { recommendations } = await chargly.listPricingRecommendations({ status: "pending" });

for (const rec of recommendations) {
  const explanation = await chargly.explainPricingRecommendation({
    recommendationId: rec.id,
  });
  console.log(`${rec.feature}: ${rec.currentCredits} → ${rec.recommendedCredits} credits`);
  console.log(`Reason: ${explanation.reason} (${explanation.confidence} confidence)`);

  // Apply or reject
  await chargly.applyPricingRecommendation({ recommendationId: rec.id });
}

Configuration

| Option | Type | Default | Description | | -------- | ------ | -------------------------- | ------------------------------ | | apiKey | string | required | Your Chargly secret API key | | baseUrl| string | https://api.chargly.ai | Override API base URL |