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

@agent-bill/sdk

v0.2.1

Published

The 'Stripe' for x402 — add USDC payments to any API in two lines

Readme

@agent-bill/sdk

The "Stripe" for x402. Make any API payable by an AI agent in two lines of code.

Built on Base · Powered by x402 V2 · Settles in USDC

One package for both the server (payment wall) and client (paying agent).

Install

npm install @agent-bill/sdk

Quick Start: Server (Express)

import express from "express";
import { agentBill, requirePayment } from "@agent-bill/sdk";

const app = express();

agentBill.init({
  receivingAddress: "0xYourWalletAddress",
  network: "base-sepolia",
});

app.get(
  "/api/weather",
  requirePayment({ amount: "0.01", currency: "USDC", description: "Weather data" }),
  (req, res) => {
    res.json({ city: "New York", temp: "72°F" });
  }
);

app.listen(3000);

Quick Start: Client (Paying Agent)

import { createPayingClient } from "@agent-bill/sdk/client";

const client = createPayingClient({
  privateKey: "0xYourWalletPrivateKey",
  network: "base-sepolia",
});

const response = await client.fetch("http://localhost:3000/api/weather");
const data = await response.json();

Next.js (App Router)

1. Initialize once

// lib/agentbill.ts
import { agentBill } from "@agent-bill/sdk";

agentBill.init({
  receivingAddress: "0xYourWalletAddress",
  network: "base-sepolia",
});

2. Protect a route handler

// app/api/weather/route.ts
import "../../lib/agentbill";
import { withPayment } from "@agent-bill/sdk/server";
import { NextRequest, NextResponse } from "next/server";

async function handler(req: NextRequest) {
  return NextResponse.json({ city: "New York", temp: "72°F" });
}

export const GET = withPayment(
  { amount: "0.01", currency: "USDC", description: "Weather data" },
  handler
);

Quick Start: Server (Hono)

Works on Cloudflare Workers, Deno, Bun, and Node.js.

import { Hono } from "hono";
import { agentBill } from "@agent-bill/sdk";
import { requirePayment } from "@agent-bill/sdk/hono";

agentBill.init({
  receivingAddress: "0xYourWalletAddress",
  network: "base-sepolia",
});

const app = new Hono();

app.get(
  "/api/weather",
  requirePayment({ amount: "0.01", currency: "USDC", description: "Weather data" }),
  (c) => c.json({ city: "New York", temp: "72°F" })
);

export default app;

How It Works

  1. A request hits your protected endpoint with no payment header
  2. Server returns 402 Payment Required with payment details (price, address, network)
  3. Client signs a USDC payment authorization using your wallet
  4. Client retries with the payment signature
  5. Server verifies via the x402 facilitator and returns data

No API keys, no subscriptions, no human in the loop.

API

agentBill.init(config)

Call once when your server starts.

| Field | Type | Description | |---|---|---| | receivingAddress | string | Wallet address that receives USDC payments | | network | "base-mainnet" \| "base-sepolia" | Network to accept payments on |

requirePayment(options) (Express)

Returns Express middleware. Place before your route handler.

| Field | Type | Description | |---|---|---| | amount | string | Amount in USD, e.g. "0.01" | | currency | "USDC" | Currency (USDC only for now) | | description | string (optional) | Shown in the 402 response |

requirePayment(options) (Hono)

Returns Hono middleware. Import from @agent-bill/sdk/hono. Place before your route handler.

| Field | Type | Description | |---|---|---| | amount | string | Amount in USD, e.g. "0.01" | | currency | "USDC" | Currency (USDC only for now) | | description | string (optional) | Shown in the 402 response |

withPayment(options, handler) (Next.js)

Wraps a Next.js App Router route handler with a payment wall. Import from @agent-bill/sdk/server.

| Field | Type | Description | |---|---|---| | options.amount | string | Amount in USD, e.g. "0.01" | | options.currency | "USDC" | Currency (USDC only for now) | | options.description | string (optional) | Shown in the 402 response | | handler | (req: NextRequest) => Promise<NextResponse> | Route handler to protect |

createPayingClient(config)

Import from @agent-bill/sdk/client.

| Field | Type | Description | |---|---|---| | privateKey | 0x${string} | Wallet private key for payments | | network | "base-mainnet" \| "base-sepolia" | Network to use | | rpcUrl | string (optional) | Custom RPC URL | | baseFetch | typeof fetch (optional) | Underlying fetch to wrap |

Returns a PayingClient with .fetch() and .address.

Networks

| Config value | Chain | |---|---| | "base-sepolia" | Base Sepolia testnet (development) | | "base-mainnet" | Base mainnet (production) |

Why Base?

Base has near-zero gas fees, making micro-transactions (e.g. $0.01) economically viable. Settles in USDC, compatible with Coinbase AgentKit and the x402 facilitator out of the box.

Related Packages

| Package | Description | |---|---| | @agent-bill/middleware | Server middleware only (Express + Next.js) | | @agent-bill/client | Payment-enabled fetch client only |

License

MIT

GitHub · AgentBill is not affiliated with Coinbase. x402 is an open protocol.