A cryptocurrency data API that accepts x402 payments.
GET /api/health- Health check
GET /api/v1/price/:symbol- Get current priceGET /api/v1/prices- Get all pricesGET /api/v1/trending- Get trending coins
GET /api/v1/premium/analysis/:symbol- Detailed technical analysisGET /api/v1/premium/signals- Trading signals
npm installexport X402_WALLET=0xYourWalletAddress# Development mode (without x402)
npm run dev
# Production mode (with x402)
npm run build
npm start# Free endpoint
curl http://localhost:3000/api/health
# Paid endpoint (will return 402 when x402 is enabled)
curl http://localhost:3000/api/v1/price/BTCUncomment the x402 wrapper in src/index.ts:
import { wrapExpressWithX402 } from "@nirholas/x402-deploy/express";
import config from "./x402.config.json";
// ... your routes ...
const wrappedApp = wrapExpressWithX402(app, config);
wrappedApp.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});Edit x402.config.json to customize:
- Wallet address: Where payments go
- Network: Which blockchain (Arbitrum, Base, etc.)
- Pricing: Cost per endpoint
- Discovery: How AI agents find your API
- Client requests a paid endpoint
- Server returns
402 Payment Requiredwith payment details - Client makes payment via x402 protocol
- Client retries with
X-PAYMENTheader - Server verifies payment and returns data
Configure Claude Desktop with x402 support:
{
"mcpServers": {
"universal-crypto": {
"command": "npx",
"args": ["@nirholas/universal-crypto-mcp"],
"env": {
"X402_PRIVATE_KEY": "0xYourPrivateKey"
}
}
}
}Then ask Claude:
"Get the BTC analysis from http://localhost:3000/api/v1/premium/analysis/BTC"
Claude will:
- Make the request
- See the $0.01 cost
- Ask for confirmation
- Make the payment
- Return the analysis
paid-api/
├── src/
│ └── index.ts # API server
├── x402.config.json # x402 configuration
├── package.json # Dependencies
└── README.md # This file
- Deploy to Vercel/Railway
- Add more premium endpoints
- Set up analytics dashboard
- See x402-deploy docs