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

pulsarpay-sdk

v0.2.0

Published

Official TypeScript SDK for the Pulsarpay API — automated payment infrastructure for APIs and autonomous agents.

Readme

pulsarpay-sdk

npm version npm downloads CI Bundle size GitHub issues License: MIT Node.js ≥18 TypeScript

Official TypeScript SDK for the Pulsarpay API — automated payment infrastructure for APIs and autonomous agents.

Installation

npm install pulsarpay-sdk
# or
pnpm add pulsarpay-sdk
# or
yarn add pulsarpay-sdk

Quick Start

import { PulsarpayClient } from "pulsarpay-sdk";

const client = new PulsarpayClient({
  agentKey: process.env.PULSARPAY_AGENT_KEY!,
});

Usage

Register an Agent

Register your agent once during onboarding. The apiKey is returned only once — store it immediately.

const result = await client.agents.register({
  name: "my-inference-agent",
  email: "[email protected]",
  website: "https://mycompany.com",
});

console.log(result.apiKey);   // ag_live_... (save this!)
console.log(result.enabled);  // false — contact [email protected] for activation

Create a Charge

Debit a user's balance. Requires the user's pp_live_... key. An idempotency key is auto-generated if not provided.

const charge = await client.payments.createCharge(
  {
    amount: 0.5,
    currency: "USDC",
    description: "AI Inference - 1000 tokens",
  },
  {
    userKey: "pp_live_7698774c...",
    // idempotencyKey: "uuid-v4-optional", // auto-generated if omitted
  }
);

console.log(charge.chargeId); // cmnnfoagf0003jk04suqxf3k9
console.log(charge.reused);   // true if idempotency key was reused

Get a Charge

Poll the status of a specific charge.

const charge = await client.payments.getCharge("cmn3tney00001l104hudm7fgy");

console.log(charge.status);    // "PENDING" | "SUCCESS" | "FAILED" | "EXPIRED"
console.log(charge.amount);    // 0.5
console.log(charge.currency);  // "USDC"

List Charges

Retrieve a paginated list of all charges for reconciliation and auditing.

const result = await client.payments.listCharges({ page: 1, limit: 20 });

console.log(result.pagination.total);      // 142
console.log(result.pagination.totalPages); // 8

for (const charge of result.data) {
  console.log(charge.id, charge.status, charge.amount);
}

Get Earnings

View your agent's net earnings, total successful charges, and pending balance. Each supported currency (USDC and USD) has an independent balance entry.

const { earnings } = await client.payments.getEarnings();

for (const entry of earnings) {
  console.log(entry.currency);        // "USDC" | "USD"
  console.log(entry.totalEarned);     // net earned after fees
  console.log(entry.totalCharges);    // number of successful charges
  console.log(entry.currentBalance);  // available for withdrawal
}

List Withdrawals

Retrieve all withdrawal records, or a single one by ID.

import type { PayoutListResponse, PayoutSingleResponse } from "pulsarpay-sdk";

// All withdrawals
const { payouts } = await client.payments.listWithdrawals() as PayoutListResponse;
for (const p of payouts) {
  console.log(p.id, p.status, p.amount); // "cmoq..." "COMPLETED" 97
}

// Single withdrawal by ID
const { payout } = await client.payments.listWithdrawals({
  payoutId: "cmoqbpavp00071ry1t2iyr1hw",
}) as PayoutSingleResponse;

console.log(payout.status);                   // "PENDING" | "COMPLETED" | "FAILED"
console.log(payout.destination.walletAddress); // "7AEai..."
console.log(payout.fee, payout.platformFeeRate); // 3, "3%"

Withdraw Funds

Transfer earned balance to a Solana wallet (USDC) or a PayPal account (USD). Minimum withdrawal is 1.00. A 3% platform fee is deducted from the gross amount.

// USDC → Solana wallet
const payout = await client.payments.withdraw({
  amount: 100,
  currency: "USDC",
  walletAddress: "8ixbQzsFc9FkxegG7aumq3h1XCGDkRSN23xeLTnZiyHr",
});

console.log(payout.success);                    // true
console.log(payout.payoutId);                   // "cmoqbpavp00071ry1t2iyr1hw"
console.log(payout.breakdown.netAmount);        // 97
console.log(payout.breakdown.platformFee);      // 3
console.log(payout.breakdown.platformFeeRate);  // "3%"
console.log(payout.breakdown.network);          // "SOL"

// USD → PayPal
const payout = await client.payments.withdraw({
  amount: 50,
  currency: "USD",
  walletAddress: "[email protected]",
});

console.log(payout.breakdown.network);  // "PAYPAL"

Error Handling

All errors extend PulsarpayError and include a statusCode and raw body.

import {
  PulsarpayInsufficientFundsError,
  PulsarpayUnauthorizedError,
  PulsarpayBadRequestError,
  PulsarpayNotFoundError,
  PulsarpayConflictError,
  PulsarpayNetworkError,
  PulsarpayError,
} from "pulsarpay-sdk";

try {
  await client.payments.createCharge(data, options);
} catch (err) {
  if (err instanceof PulsarpayInsufficientFundsError) {
    console.error("User has no funds:", err.message);
  } else if (err instanceof PulsarpayUnauthorizedError) {
    console.error("Invalid agent or user key:", err.message);
  } else if (err instanceof PulsarpayBadRequestError) {
    console.error("Validation error:", err.message); // e.g. currency mismatch
  } else if (err instanceof PulsarpayNetworkError) {
    console.error("Network/timeout error:", err.message);
  } else if (err instanceof PulsarpayError) {
    console.error(`Unexpected error [${err.statusCode}]:`, err.message);
  }
}

| Class | HTTP Status | When | |---|---|---| | PulsarpayBadRequestError | 400 | Validation / logic error | | PulsarpayUnauthorizedError | 401 | Invalid or disabled key | | PulsarpayInsufficientFundsError | 402 | User balance too low | | PulsarpayNotFoundError | 404 | Charge ID not found | | PulsarpayConflictError | 409 | Duplicate agent name | | PulsarpayNetworkError | — | Timeout or network failure |


Configuration

const client = new PulsarpayClient({
  agentKey: "ag_live_...",   // required
  baseUrl: "https://...",    // optional — defaults to https://www.pulsarpay.io
  timeout: 15_000,           // optional — defaults to 30000ms
});

Requirements

  • Node.js ≥ 18 (uses native fetch and crypto.randomUUID)
  • TypeScript ≥ 5.0 (optional but recommended)

Development & Testing

# Run all tests
npm test

# Watch mode
npm run test:watch

# Coverage report (enforces ≥ 85% threshold)
npm run test:coverage

Coverage is enforced at 85% for lines, functions, branches, and statements via @vitest/coverage-v8. Running npm run test:coverage will fail the build if any threshold is not met.

Test structure

src/__tests__/
├── helpers.ts          ← shared fixtures and fetch mock utilities
├── errors.test.ts      ← all 6 error classes
├── http-client.test.ts ← HTTP mappings, timeout, network errors
├── client.test.ts      ← PulsarpayClient constructor
├── agents.test.ts      ← agents.register()
└── payments.test.ts    ← createCharge, getCharge, listCharges, getEarnings, listWithdrawals, withdraw