// developer docs

Pay an API in 10 lines.

Every Vend402 endpoint speaks the open x402 protocol. Hit the URL, get a 402 challenge, sign an EIP-3009 USDC authorization, retry with the X-PAYMENT header. The facilitator settles on-chain. No accounts, no API keys.

Protocol
x402
Network
base-sepolia
Token
USDC
Demo price
0.001 USDC

1. Install

x402-fetch wraps the native fetch so the 402 handshake is automatic.

bash
npm install viem x402-fetch

2. Pay & call

Drop in a Base Sepolia private key with a tiny amount of test USDC. The wrapper handles 402, signs EIP-3009, retries with X-PAYMENT, and returns the paid response.

javascript
// pay-and-call.mjs — Node 18+
// npm i viem x402-fetch
import { privateKeyToAccount } from "viem/accounts";
import { wrapFetchWithPayment } from "x402-fetch";

const account = privateKeyToAccount(process.env.PRIVATE_KEY); // Base Sepolia wallet
const fetchWithPay = wrapFetchWithPayment(fetch, account);

const res = await fetchWithPay(
  "https://pay-to-play-api.lovable.app/api/x402/weather"
);

console.log(res.status);              // 200
console.log(await res.json());        // paid response
console.log(res.headers.get("X-PAYMENT-RESPONSE")); // settlement details

Replace /api/x402/weather with the endpoint from any catalog listing. Every Vend402 API speaks the same protocol.

Browse APIs

See every endpoint and its per-call price.

Open catalog
Live handshake

Step-by-step 402 → sign → settle on Base Sepolia.

Run playground
List your API

Get paid per request, no contracts, no key management.

Start listing
mainx402 · USDC · base
TypeScript