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.Initial Request: Tries to access resource (no payment)
- 2.402 Detection: Server returns 402 with payment spec
- 3.Extract Requirements: Gets network, amount, recipient
- 4.Build & Sign: Creates and signs Aptos transaction
- 5.Retry with Payment: Resends request with X-PAYMENT header
- 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.