Aptos x402 LogoAptos x402

x402 Payment Protocol Demo

HTTP 402 on Aptos Blockchain

API Response

No response yet. Make a request to see the response here.

Access Protected Weather API

Click below to access the protected weather API. The x402axios.get() function will automatically handle the payment if required!

💡 Open DevTools Network tab to see 2 requests: first without payment (gets 402), then with payment (gets data)

How x402Axios works

  1. 1.Initial Request: Tries to access resource (no payment)
  2. 2.402 Detection: Server returns 402 with payment spec
  3. 3.Extract Requirements: Gets network, amount, recipient from 402
  4. 4.Build & Sign: Creates and signs transaction automatically
  5. 5.Retry with Payment: Resends request with X-PAYMENT header
  6. 6.Verification: Middleware calls facilitator to verify
  7. 7.Settlement: Facilitator submits to Aptos blockchain
  8. 8.Success: Returns resource + transaction hash

✨ Just call x402Axios({ privateKey, url }) - that's it!