Monetize your APIs with blockchain micropayments.
Install via npm
Just configure middleware. Your API routes stay clean—no payment code needed.
Built on Aptos blockchain. Verification in <50ms, settlement in 1-3 seconds.
Follows Coinbase x402 specification for machine-to-machine micropayments.
Three steps to monetize your APIs
// middleware.ts
import { paymentMiddleware }
  from 'aptos-x402';
export const middleware =
  paymentMiddleware(
    process.env
      .PAYMENT_RECIPIENT_ADDRESS!,
    {
      '/api/premium/weather': {
        price: '1000000',
        network: 'testnet',
      }
    },
    { url: process.env
        .FACILITATOR_URL! }
  );// route.ts
import { NextResponse }
  from 'next/server';
export async function GET() {
  // Payment already verified!
  return NextResponse.json({
    temperature: 72,
    condition: 'Sunny',
    premium: true
  });
}// client.ts
import { x402axios }
  from 'aptos-x402';
const result = await x402axios.get(
  'https://api.example.com/premium/weather',
  {
    privateKey: '0x...'
  }
);
// Done! Payment handled
console.log(result.data);