x402 example: a real API call you can run

Most x402 examples point at a throwaway echo server. This one calls a real endpoint that returns a real US weather forecast — and you can run it in under a minute.

The fastest example: a free trial call

You can verify the endpoint returns real data with zero setup — no wallet, no payment — using a trial call (one free real call per endpoint per hour):

cURL — free trialbash
# Free trial call — real data, no payment, no signup (1/endpoint/hour):
curl "https://2s.io/api/weather/zip?zip=94103&trial=1"

The real thing: probe, sign, retry

A paid x402 call is a probe that returns 402, then a signed retry. First, see the 402 envelope:

cURL — probebash
# 1. Probe with no auth → HTTP 402 + the x402 PaymentRequirements envelope:
curl -i "https://2s.io/api/weather/zip?zip=94103"
# → 402 Payment Required
# → body: { "x402Version": 2, "accepts": [ { ...payTo, maxAmountRequired, network... } ], "error": "..." }

Pay with one line using an SDK

The SDKs handle the whole probe → sign → retry loop. Fund any EVM wallet with a little USDC on Base and call the endpoint directly:

TypeScript — @2sio/sdktypescript
// npm i @2sio/sdk
import { TwoS } from '@2sio/sdk'

// Fund any EVM wallet with a little USDC on Base. No signup, no API key.
const client = new TwoS({ privateKey: process.env.EVM_PRIVATE_KEY as `0x${string}` })

const res = await client.weather.zip({ zip: '94103' })
console.log(res.data)          // real National Weather Service forecast
console.log(res.costUsd)       // what this call cost, in USDC
console.log(res.settlement?.txHash)  // on-chain settlement tx

The same call in Python:

Python — 2siopython
# pip install 2sio
import os
from twosio import TwoS

client = TwoS(private_key=os.environ["EVM_PRIVATE_KEY"])

res = client.weather.zip(zip="94103")
print(res.data)        # real forecast
print(res.cost_usd)    # USDC charged
print((res.settlement or {}).get("tx_hash"))

Call a live x402 API right now — no signup.

Browse the full endpoint directory, grab the quickstart, or read the llms.txt manifest. Every endpoint is keyless and pay-per-call.

FAQ

Can I really run an x402 example without signing up?
Yes. The trial call above returns real data with no wallet and no payment. For unlimited calls, fund a wallet with USDC and use the SDK — still no signup or API key.
What does the example endpoint return?
The /api/weather/zip endpoint returns the official US National Weather Service forecast for a ZIP code. Every other endpoint in the catalog uses the identical x402 flow.
Which networks can I pay on?
USDC on Base (EIP-3009) or USDC on Solana (SPL transfer). The 402 envelope lists every supported rail; pick the one you hold.

Related

Topics: x402 example · x402 api example · how to call an x402 api · x402 demo · x402 client example