x402-deploy Overview
x402-deploy is a deployment toolkit for creating paid APIs that accept cryptocurrency payments.
What is x402-deploy?
x402-deploy enables you to:
- Create paid APIs with simple configuration
- Accept crypto payments automatically (USDC, USDs)
- Deploy anywhere (Vercel, AWS, Docker, etc.)
- Register in the AI agent discovery network
Key Features
π One-Command Deploy
π° Flexible Pricing
{
"pricing": {
"routes": {
"GET /api/free/*": "free",
"GET /api/basic/*": "$0.001",
"GET /api/premium/*": "$0.01"
}
}
}
π AI Agent Discovery
Your API is automatically discoverable by AI agents:
// AI agents can find your API
const apis = await discover({
category: "weather",
maxPrice: "$0.01"
});
π Built-in Dashboard
Monitor revenue, usage, and analytics in real-time.
Quick Start
1. Create Config File
Create x402.config.json:
{
"name": "my-paid-api",
"payment": {
"wallet": "0xYourWalletAddress",
"network": "eip155:42161"
},
"pricing": {
"routes": {
"GET /api/*": "$0.001"
}
}
}
2. Wrap Your API
import express from "express";
import { wrapWithX402 } from "@nirholas/x402-deploy/gateway";
const app = express();
app.get("/api/data", (req, res) => {
res.json({ data: "premium content" });
});
// Add x402 payment layer
const wrappedApp = wrapWithX402(app);
wrappedApp.listen(3000);
3. Deploy
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β x402-deploy Stack β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β Your API β β x402 Gateway β β
β β (Express, ββββββ - Payment β β
β β Fastify, β β Verification β β
β β Next.js) β β - Rate Limitingβ β
β ββββββββββββββββββββ β - Logging β β
β ββββββββββ¬ββββββββββ β
β β β
β ββββββββββΌββββββββββ β
β β Discovery β β
β β - Registration β β
β β - Searchable β β
β β - Categories β β
β ββββββββββ¬ββββββββββ β
β β β
β ββββββββββΌββββββββββ β
β β Dashboard β β
β β - Revenue β β
β β - Analytics β β
β β - Settings β β
β ββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Use Cases
Paid Data APIs
{
"pricing": {
"routes": {
"GET /api/price/:symbol": "$0.0001",
"GET /api/forecast/:symbol": "$0.01"
}
}
}
Compute APIs
Premium Content
Supported Frameworks
| Framework | Package |
|---|---|
| Express | @nirholas/x402-deploy/express |
| Fastify | @nirholas/x402-deploy/fastify |
| Next.js | @nirholas/x402-deploy/next |
| Hono | @nirholas/x402-deploy/hono |
| Gin (Go) | x402/gin-gonic |
| Python | x402/python |
| Java | x402/java |
Deployment Targets
- Vercel - Serverless functions
- AWS Lambda - Serverless
- Docker - Containers
- Railway - One-click deploy
- Fly.io - Edge deployment
- Self-hosted - Any Node.js server
Documentation
- Quick Start - Get started in 5 minutes
- Configuration - Full configuration reference
- Providers - Payment providers and networks
- Discovery - AI agent discovery network
Related
- Payments Package - x402 client for paying APIs
- Examples - Working examples