Demo
ready to fetch
A live L402 round trip against a real endpoint. Fetch a resource; if it is payment-gated you get a 402 challenge, pay the invoice, and retry with the resulting credential to receive the data. Point it at any L402 endpoint, or bring your own credential to skip straight to the retry.
Endpoint URL
BYOC — Bring Your Own Credential
Recipe code
const id = Math.floor(Math.random() * 1025) + 1;const endpoint = "https://prod-voltage.vercel.app/pokemon/{id}".replace("{id}", String(id));const init = { headers: { accept: "application/json" }, cache: "no-store" };const credential = cachedCredential?.endpointTemplate === "https://prod-voltage.vercel.app/pokemon/{id}"? cachedCredential.credential: null;const result = await fetchPaidResource(endpoint, credential? withAuthorization(init, credential): init,);if (result.status === "challenge") {// Pay invoice, then cache Authorization per L402 protocol-specification.md §8.}