{"_id":"@agent-bill/sdk","_rev":"4-5ef1c24bbeb257f0225545c8a1c2e14b","name":"@agent-bill/sdk","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@agent-bill/sdk","version":"0.1.0","license":"MIT","_id":"@agent-bill/sdk@0.1.0","maintainers":[{"name":"mulandi","email":"mulandicecilia4@gmail.com"}],"dist":{"shasum":"203336c6643b389f2ec475d27237ebcdaf16e0d1","tarball":"https://registry.npmjs.org/@agent-bill/sdk/-/sdk-0.1.0.tgz","fileCount":37,"integrity":"sha512-IU0xHrWAApKotBkVgcfPUIf6RPJ0a/paqHMkEipwoB7esK7dmQkWTOqNq/hPrW8qIXpJvoQnJeqAuO5C+xMhSA==","signatures":[{"sig":"MEUCIQCy6Bfyaz4eDyS2fGbN/MisWbXifMNh1URW5wU3aqyKagIgcqvTJy6mIvkBDegS6LS8cC3LI3MAC3iBypOk2yZzCPg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22013},"main":"dist/index.js","_from":"file:agent-bill-sdk-0.1.0.tgz","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./client":{"types":"./dist/client.d.ts","default":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","default":"./dist/server.js"}},"gitHead":"d08d62018a6ee7211540dea065f8020dd8a9aa48","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mulandi","email":"mulandicecilia4@gmail.com"},"_resolved":"/tmp/c8bfe36f6948a7015d6df5bd2552de05/agent-bill-sdk-0.1.0.tgz","_integrity":"sha512-IU0xHrWAApKotBkVgcfPUIf6RPJ0a/paqHMkEipwoB7esK7dmQkWTOqNq/hPrW8qIXpJvoQnJeqAuO5C+xMhSA==","_npmVersion":"10.9.0","description":"The 'Stripe' for x402 — add USDC payments to any API in two lines","directories":{},"_nodeVersion":"21.7.3","dependencies":{"viem":"^2.47.0","express":"^5.2.1","@x402/evm":"^2.6.0","@x402/core":"^2.7.0","@x402/next":"^2.6.0","@x402/fetch":"^2.6.0","@x402/express":"^2.6.0","@coinbase/x402":"^2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.0.0","typescript":"^5.9.3","@types/node":"^25.5.0","@types/express":"^5.0.6"},"peerDependencies":{"next":">=14.0.0"},"peerDependenciesMeta":{"next":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1775421597464_0.44977261287808434","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@agent-bill/sdk","version":"0.1.2","license":"MIT","_id":"@agent-bill/sdk@0.1.2","maintainers":[{"name":"mulandi","email":"mulandicecilia4@gmail.com"}],"dist":{"shasum":"eb8f2a11c50d13daa08636082211984f4fe4d180","tarball":"https://registry.npmjs.org/@agent-bill/sdk/-/sdk-0.1.2.tgz","fileCount":38,"integrity":"sha512-mcLNCKoSA7fNc1rZ4DiO7nFhXYVVtwW9M1K0bchtNT2RzhTXiYo8eWtptIA4ASE9MgeyuagP8shtOCoHpthknQ==","signatures":[{"sig":"MEUCIQC0WFCJxH690sSrIwh6S2GIH1zKr9XzLchtP3kUSM12GgIgMxI9Yd3KF7dT/r0X9MSQuhDEnPaOlm057LlqPTu4M6g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26570},"main":"dist/index.js","_from":"file:agent-bill-sdk-0.1.2.tgz","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./client":{"types":"./dist/client.d.ts","default":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","default":"./dist/server.js"}},"gitHead":"d08d62018a6ee7211540dea065f8020dd8a9aa48","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mulandi","email":"mulandicecilia4@gmail.com"},"_resolved":"/tmp/11c29f9ad75da9fe124b4c01dfbe4788/agent-bill-sdk-0.1.2.tgz","_integrity":"sha512-mcLNCKoSA7fNc1rZ4DiO7nFhXYVVtwW9M1K0bchtNT2RzhTXiYo8eWtptIA4ASE9MgeyuagP8shtOCoHpthknQ==","_npmVersion":"10.9.0","description":"The 'Stripe' for x402 — add USDC payments to any API in two lines","directories":{},"_nodeVersion":"21.7.3","dependencies":{"viem":"^2.47.0","express":"^5.2.1","@x402/evm":"^2.6.0","@x402/core":"^2.7.0","@x402/next":"^2.6.0","@x402/fetch":"^2.6.0","@x402/express":"^2.6.0","@coinbase/x402":"^2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.0.0","typescript":"^5.9.3","@types/node":"^25.5.0","@types/express":"^5.0.6"},"peerDependencies":{"next":">=14.0.0"},"peerDependenciesMeta":{"next":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.2_1775427958363_0.8919742079505684","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@agent-bill/sdk","version":"0.2.0","license":"MIT","_id":"@agent-bill/sdk@0.2.0","maintainers":[{"name":"mulandi","email":"mulandicecilia4@gmail.com"}],"dist":{"shasum":"6891291cd21c76c3476e29901bf885f43481a104","tarball":"https://registry.npmjs.org/@agent-bill/sdk/-/sdk-0.2.0.tgz","fileCount":110,"integrity":"sha512-VuiswS1Y/EQLbNKu22i7JN2FFi6+0qEPYs1egLKcYs/NC2CkSHkAMaX0nQMXlGlq6cCg+KXI6+ueDFYomurjiQ==","signatures":[{"sig":"MEQCIDpOaVVqxwrUFUY5XAo2BByF2WttqsyDP4WMbRBQnwV6AiAgkQfvfl1XCVxO/FnFqPH0j9gU8CSW6gfR9yN6p/0TDA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":132734},"main":"dist/index.js","_from":"file:agent-bill-sdk-0.2.0.tgz","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./hono":{"types":"./dist/hono/index.d.ts","default":"./dist/hono/index.js"},"./client":{"types":"./dist/client.d.ts","default":"./dist/client.js"},"./server":{"types":"./dist/server.d.ts","default":"./dist/server.js"},"./fastify":{"types":"./dist/fastify/index.d.ts","default":"./dist/fastify/index.js"},"./dashboard":{"types":"./dist/dashboard/index.d.ts","default":"./dist/dashboard/index.js"}},"gitHead":"d08d62018a6ee7211540dea065f8020dd8a9aa48","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mulandi","email":"mulandicecilia4@gmail.com"},"_resolved":"/tmp/ac7c5ec846c5d77bf305130fbcebdfff/agent-bill-sdk-0.2.0.tgz","_integrity":"sha512-VuiswS1Y/EQLbNKu22i7JN2FFi6+0qEPYs1egLKcYs/NC2CkSHkAMaX0nQMXlGlq6cCg+KXI6+ueDFYomurjiQ==","_npmVersion":"10.9.0","description":"The 'Stripe' for x402 — add USDC payments to any API in two lines","directories":{},"_nodeVersion":"21.7.3","dependencies":{"viem":"^2.47.0","express":"^5.2.1","@x402/evm":"^2.6.0","@x402/core":"~2.6.0","@x402/next":"^2.6.0","@x402/fetch":"^2.6.0","@coinbase/x402":"^2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^4.0.0","next":"^15.0.0","fastify":"^5.0.0","typescript":"^5.9.3","@types/node":"^25.5.0","@types/express":"^5.0.6"},"peerDependencies":{"hono":">=4.0.0","next":">=14.0.0","fastify":">=5.0.0"},"peerDependenciesMeta":{"hono":{"optional":true},"next":{"optional":true},"fastify":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.2.0_1775462571593_0.09890900066412511","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@agent-bill/sdk","version":"0.2.1","description":"The 'Stripe' for x402 — add USDC payments to any API in two lines","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./server":{"types":"./dist/server.d.ts","default":"./dist/server.js"},"./client":{"types":"./dist/client.d.ts","default":"./dist/client.js"},"./hono":{"types":"./dist/hono/index.d.ts","default":"./dist/hono/index.js"},"./fastify":{"types":"./dist/fastify/index.d.ts","default":"./dist/fastify/index.js"},"./dashboard":{"types":"./dist/dashboard/index.d.ts","default":"./dist/dashboard/index.js"}},"scripts":{"build":"tsc","dev":"tsc --watch"},"license":"MIT","publishConfig":{"access":"public"},"peerDependencies":{"next":">=14.0.0","hono":">=4.0.0","fastify":">=5.0.0"},"peerDependenciesMeta":{"next":{"optional":true},"hono":{"optional":true},"fastify":{"optional":true}},"devDependencies":{"@types/express":"^5.0.6","@types/node":"^25.5.0","fastify":"^5.0.0","hono":"^4.0.0","next":"^15.0.0","typescript":"^5.9.3"},"dependencies":{"@coinbase/x402":"^2.1.0","@x402/core":"~2.6.0","@x402/evm":"^2.6.0","@x402/fetch":"^2.6.0","@x402/next":"^2.6.0","express":"^5.2.1","viem":"^2.47.0"},"_id":"@agent-bill/sdk@0.2.1","gitHead":"fa7ee998ed504eb854304473185db3c2b8e8a364","_nodeVersion":"21.7.3","_npmVersion":"10.9.0","dist":{"integrity":"sha512-/fpn2Nt5sQG0oUbAGXtULiHlkFlLMZTy/Rgur6GthmnGupHfqEpfFYDAumtkE+y+3wHW6mq16sKymeHm3yKQPA==","shasum":"b8f55a03a34734a7c60e701144e01389d29dc192","tarball":"https://registry.npmjs.org/@agent-bill/sdk/-/sdk-0.2.1.tgz","fileCount":114,"unpackedSize":136173,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIC36r3LbQ5jBEsj8NldRnAmrC9g0CsRv5wV/RHkpszG7AiBxA4btPfm0C0X9IoeNy9dyhK6tc+cCzrd6wGdC8OZIog=="}]},"_npmUser":{"name":"mulandi","email":"mulandicecilia4@gmail.com"},"directories":{},"maintainers":[{"name":"mulandi","email":"mulandicecilia4@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.2.1_1776151896107_0.04547423546564988"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-05T20:39:57.103Z","modified":"2026-04-14T07:31:36.380Z","0.1.0":"2026-04-05T20:39:57.613Z","0.1.2":"2026-04-05T22:25:58.499Z","0.2.0":"2026-04-06T08:02:51.739Z","0.2.1":"2026-04-14T07:31:36.242Z"},"license":"MIT","description":"The 'Stripe' for x402 — add USDC payments to any API in two lines","maintainers":[{"name":"mulandi","email":"mulandicecilia4@gmail.com"}],"readme":"# @agent-bill/sdk\n\n**The \"Stripe\" for x402. Make any API payable by an AI agent in two lines of code.**\n\nBuilt on [Base](https://base.org) · Powered by [x402 V2](https://x402.org) · Settles in USDC\n\nOne package for both the **server** (payment wall) and **client** (paying agent).\n\n## Install\n\n```bash\nnpm install @agent-bill/sdk\n```\n\n## Quick Start: Server (Express)\n\n```typescript\nimport express from \"express\";\nimport { agentBill, requirePayment } from \"@agent-bill/sdk\";\n\nconst app = express();\n\nagentBill.init({\n  receivingAddress: \"0xYourWalletAddress\",\n  network: \"base-sepolia\",\n});\n\napp.get(\n  \"/api/weather\",\n  requirePayment({ amount: \"0.01\", currency: \"USDC\", description: \"Weather data\" }),\n  (req, res) => {\n    res.json({ city: \"New York\", temp: \"72°F\" });\n  }\n);\n\napp.listen(3000);\n```\n\n## Quick Start: Client (Paying Agent)\n\n```typescript\nimport { createPayingClient } from \"@agent-bill/sdk/client\";\n\nconst client = createPayingClient({\n  privateKey: \"0xYourWalletPrivateKey\",\n  network: \"base-sepolia\",\n});\n\nconst response = await client.fetch(\"http://localhost:3000/api/weather\");\nconst data = await response.json();\n```\n\n## Next.js (App Router)\n\n### 1. Initialize once\n\n```typescript\n// lib/agentbill.ts\nimport { agentBill } from \"@agent-bill/sdk\";\n\nagentBill.init({\n  receivingAddress: \"0xYourWalletAddress\",\n  network: \"base-sepolia\",\n});\n```\n\n### 2. Protect a route handler\n\n```typescript\n// app/api/weather/route.ts\nimport \"../../lib/agentbill\";\nimport { withPayment } from \"@agent-bill/sdk/server\";\nimport { NextRequest, NextResponse } from \"next/server\";\n\nasync function handler(req: NextRequest) {\n  return NextResponse.json({ city: \"New York\", temp: \"72°F\" });\n}\n\nexport const GET = withPayment(\n  { amount: \"0.01\", currency: \"USDC\", description: \"Weather data\" },\n  handler\n);\n```\n\n## Quick Start: Server (Hono)\n\nWorks on Cloudflare Workers, Deno, Bun, and Node.js.\n\n```typescript\nimport { Hono } from \"hono\";\nimport { agentBill } from \"@agent-bill/sdk\";\nimport { requirePayment } from \"@agent-bill/sdk/hono\";\n\nagentBill.init({\n  receivingAddress: \"0xYourWalletAddress\",\n  network: \"base-sepolia\",\n});\n\nconst app = new Hono();\n\napp.get(\n  \"/api/weather\",\n  requirePayment({ amount: \"0.01\", currency: \"USDC\", description: \"Weather data\" }),\n  (c) => c.json({ city: \"New York\", temp: \"72°F\" })\n);\n\nexport default app;\n```\n\n## How It Works\n\n1. A request hits your protected endpoint with no payment header\n2. Server returns `402 Payment Required` with payment details (price, address, network)\n3. Client signs a USDC payment authorization using your wallet\n4. Client retries with the payment signature\n5. Server verifies via the [x402 facilitator](https://x402.org) and returns data\n\nNo API keys, no subscriptions, no human in the loop.\n\n## API\n\n### `agentBill.init(config)`\n\nCall once when your server starts.\n\n| Field | Type | Description |\n|---|---|---|\n| `receivingAddress` | `string` | Wallet address that receives USDC payments |\n| `network` | `\"base-mainnet\" \\| \"base-sepolia\"` | Network to accept payments on |\n\n### `requirePayment(options)` (Express)\n\nReturns Express middleware. Place before your route handler.\n\n| Field | Type | Description |\n|---|---|---|\n| `amount` | `string` | Amount in USD, e.g. `\"0.01\"` |\n| `currency` | `\"USDC\"` | Currency (USDC only for now) |\n| `description` | `string` (optional) | Shown in the 402 response |\n\n### `requirePayment(options)` (Hono)\n\nReturns Hono middleware. Import from `@agent-bill/sdk/hono`. Place before your route handler.\n\n| Field | Type | Description |\n|---|---|---|\n| `amount` | `string` | Amount in USD, e.g. `\"0.01\"` |\n| `currency` | `\"USDC\"` | Currency (USDC only for now) |\n| `description` | `string` (optional) | Shown in the 402 response |\n\n### `withPayment(options, handler)` (Next.js)\n\nWraps a Next.js App Router route handler with a payment wall. Import from `@agent-bill/sdk/server`.\n\n| Field | Type | Description |\n|---|---|---|\n| `options.amount` | `string` | Amount in USD, e.g. `\"0.01\"` |\n| `options.currency` | `\"USDC\"` | Currency (USDC only for now) |\n| `options.description` | `string` (optional) | Shown in the 402 response |\n| `handler` | `(req: NextRequest) => Promise<NextResponse>` | Route handler to protect |\n\n### `createPayingClient(config)`\n\nImport from `@agent-bill/sdk/client`.\n\n| Field | Type | Description |\n|---|---|---|\n| `privateKey` | `` 0x${string} `` | Wallet private key for payments |\n| `network` | `\"base-mainnet\" \\| \"base-sepolia\"` | Network to use |\n| `rpcUrl` | `string` (optional) | Custom RPC URL |\n| `baseFetch` | `typeof fetch` (optional) | Underlying fetch to wrap |\n\nReturns a `PayingClient` with `.fetch()` and `.address`.\n\n## Networks\n\n| Config value | Chain |\n|---|---|\n| `\"base-sepolia\"` | Base Sepolia testnet (development) |\n| `\"base-mainnet\"` | Base mainnet (production) |\n\n## Why Base?\n\nBase 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.\n\n## Related Packages\n\n| Package | Description |\n|---|---|\n| [`@agent-bill/middleware`](https://www.npmjs.com/package/@agent-bill/middleware) | Server middleware only (Express + Next.js) |\n| [`@agent-bill/client`](https://www.npmjs.com/package/@agent-bill/client) | Payment-enabled fetch client only |\n\n## License\n\nMIT\n\n[GitHub](https://github.com/the-AgentBill/SDK) · _AgentBill is not affiliated with Coinbase. x402 is an open protocol._\n","readmeFilename":"README.md"}