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

@apirail/payer-sdk

v0.1.0

Published

Payer SDK for PoAPW - Proof of API-Work protocol. Call APIs and pay with Cardano native tokens.

Readme

@apirail/payer-sdk

Payer SDK for PoAPW (Proof of API-Work) - A machine-native settlement protocol where APIs earn Cardano native tokens by delivering results.

Installation

npm install @apirail/payer-sdk

Quick Start

import { PayerSDK } from '@apirail/payer-sdk';

const payer = new PayerSDK({
  baseUrl: 'https://your-poapw-server.com',
  walletId: 'your-wallet-id',
});

// Call an API - payments are handled automatically
const result = await payer.callApi('api-route-id', { data: 'your-payload' });

if (result.success) {
  console.log('Response:', result.response);
  console.log('Response time:', result.responseTimeMs, 'ms');
}

Features

  • Auto-Settle: Automatically settles on-chain when payment threshold is reached (enabled by default)
  • Off-chain Accumulation: API calls accumulate off-chain until threshold, minimizing transaction costs
  • Type-safe: Full TypeScript support with exported interfaces

Configuration

const payer = new PayerSDK({
  baseUrl: 'https://your-poapw-server.com',  // Required: PoAPW server URL
  walletId: 'your-wallet-id',                 // Required: Your payer wallet ID
  paymentMode: 'native',                      // Optional: 'native' or 'masumi' (default: 'native')
  autoSettle: true,                           // Optional: Auto-pay when threshold reached (default: true)
  onPaymentRequired: async (details) => {     // Optional: Custom settlement logic
    console.log('Payment required:', details.accumulatedAmount, 'tokens');
    return true; // Return true to settle, false to skip
  },
  onSettlement: (result) => {                 // Optional: Settlement callback
    console.log('Settled:', result.settledAmount, 'TX:', result.txHash);
  },
  onMasumiJob: (job) => {                     // Optional: Masumi job callback
    console.log('Masumi job started:', job.id);
  },
});

Payment Modes

The SDK supports two payment modes:

Native Mode (default)

Uses PoAPW's native token payment system with off-chain accumulation and batch settlement.

const payer = new PayerSDK({
  baseUrl: 'https://your-server.com',
  walletId: 'your-wallet-id',
  paymentMode: 'native',
});

Masumi Mode

Uses the Masumi Network protocol for AI agent payments with smart contract escrow.

const payer = new PayerSDK({
  baseUrl: 'https://your-server.com',
  walletId: 'your-wallet-id',
  paymentMode: 'masumi',
});

// Or switch modes at runtime
payer.setPaymentMode('masumi');

API Reference

callApi<T>(apiRouteId: string, payload?: unknown): Promise<ApiCallResult<T>>

Call a registered API. Handles payment flow automatically.

const result = await payer.callApi('api-id', { message: 'Hello' });
// result.success, result.response, result.httpStatus, result.responseTimeMs

getBalances(): Promise<BalanceInfo[]>

Get accumulated balances for all receivers.

const balances = await payer.getBalances();
// [{ receiverId, accumulatedAmount, paidAmount }]

settleBalance(receiverId: string): Promise<SettlementResult>

Manually trigger on-chain settlement for a receiver.

const result = await payer.settleBalance('receiver-wallet-id');
// result.success, result.txHash, result.settledAmount

getAvailableApis(): Promise<ApiRouteInfo[]>

List all available APIs on the network.

const apis = await payer.getAvailableApis();
// [{ id, name, endpoint, method, basePrice }]

getWalletInfo(): Promise<WalletInfo>

Get your wallet information including balance.

const wallet = await payer.getWalletInfo();
// { id, name, balance, cardanoAddress }

Payment Flow

  1. Call API - SDK sends request to PoAPW server
  2. Off-chain Accumulation - Tokens accumulate until threshold
  3. 402 Response - When threshold reached, server returns 402
  4. Auto-Settle - SDK automatically settles on-chain (if enabled)
  5. Retry - SDK retries the API call after settlement
  6. Success - API response returned to caller

License

MIT