x402 Payment Protocol Demo

HTTP 402 on Aptos Blockchain

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
  4. 4.Build & Sign: Creates and signs Aptos transaction
  5. 5.Retry with Payment: Resends request with X-PAYMENT header
  6. 6.Verify & Settle: Facilitator verifies and settles

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

API Response

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