PricePilot402 x402 Buyer Example

Use this public example to discover a payment challenge, pay with an x402-compatible client, and retry the same resource with a payment proof.

Live Provisional Routes

1. Fetch The Challenge

curl -i "https://pricepilot402.pricepilot402-arya.workers.dev/v1/market/hot-categories?limit=5"

2. Pay And Retry

curl -i "https://pricepilot402.pricepilot402-arya.workers.dev/v1/benchmark/category" \
  -H "content-type: application/json" \
  -H "Idempotency-Key: buyer-demo-001" \
  -H "PAYMENT-SIGNATURE: <x402 payment proof>" \
  --data '{"category":"web-search","network":"eip155:8453"}'

Client Pattern

const resource = "https://pricepilot402.pricepilot402-arya.workers.dev/v1/market/hot-categories?limit=5";
const challenge = await fetch(resource);

if (challenge.status !== 402) {
  throw new Error("Expected x402 payment challenge");
}

const paymentRequired = challenge.headers.get("PAYMENT-REQUIRED");

// Use your x402-compatible wallet/client to satisfy paymentRequired.
// The client should sign/pay on Base USDC and return a PAYMENT-SIGNATURE value.
const paymentSignature = await yourX402Client.createPayment({ paymentRequired });

const paid = await fetch(resource, {
  headers: {
    "Idempotency-Key": crypto.randomUUID(),
    "PAYMENT-SIGNATURE": paymentSignature
  }
});

console.log(await paid.json());

Keep your buyer private key in your own client or wallet runtime. Do not send private keys to PricePilot402.

Discovery