Interactive Demo

See x402 in Action

Experience the pay-per-request flow end-to-end. Make a request, get HTTP 402, pay with USDC, and receive your result — all within seconds.

The x402 Flow

1

Developer Protects

Wraps any endpoint with x402 middleware. Sets a price of 0.01 USDC per request.

2

Client Gets 402

Calling the endpoint returns HTTP 402 with payment details — wallet address, amount, and network.

3

Pay & Get Result

Send USDC on Base, retry with X-Payment-Tx header. The endpoint processes the request.

Live Demo Console

api-console

Click "Run Demo" to start the x402 flow

Developer Experience

Protecting your API with x402 is just two lines of code.

server.ts
import { x402 } from "xpay-sdk"

// One line — protect any endpoint
app.get("/api/analyze", 
  x402({ price: 0.01 })
);
client.ts
import { Get402Client } from "xpay-sdk"

const client = new Get402Client({ apiKey: "xpk_..." });

// Auto-handles HTTP 402
// Auto-prompts payment & retries
const data = await client.post("/api/analyze", body )
console.log(data);
// → Works seamlessly