Skip to main content

How It Works

Understanding the API architecture helps you build better integrations.

Architecture Overviewโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Client โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Web3 Identity API โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚ Data Sources โ”‚
โ”‚ (Your App) โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ (api.web3...) โ”‚ โ—„โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚ (DefiLlama, โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ Neynar, etc) โ”‚
โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
โ”‚ โ–ผ
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โ”‚ CDP Facilitator โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ (Base Network) โ”‚
โ”‚ USDC Settlement โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Request Flowโ€‹

1. Free Tierโ€‹

Client โ†’ API โ†’ Response (if under 100 calls/day)

2. Paid Request (x402)โ€‹

Client โ†’ API โ†’ 402 Response
Client โ†’ Sign Payment โ†’ API โ†’ Settle on Base โ†’ Response

Payment Protocol (x402)โ€‹

The x402 protocol enables HTTP-native micropayments:

  1. Request โ€” You call an endpoint
  2. 402 Response โ€” If free tier exhausted, API returns payment requirements
  3. Sign โ€” You sign an EIP-712 authorization to transfer USDC
  4. Retry โ€” Send the same request with the signed payment
  5. Settle โ€” API settles the payment on Base via CDP
  6. Response โ€” You receive the data

Payment Flow Diagramโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Client โ”‚ โ”‚ API โ”‚ โ”‚ Base โ”‚
โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚ โ”‚
โ”‚ 1. GET /api/ens/nick.eth โ”‚ โ”‚
โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ 2. 402 Payment Required โ”‚ โ”‚
โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ โ”‚
โ”‚ (price, recipient, etc) โ”‚ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ 3. Sign EIP-712 โ”‚ โ”‚
โ”‚ (local, no network) โ”‚ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ 4. Retry with X-PAYMENT โ”‚ โ”‚
โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ โ”‚
โ”‚ โ”‚ 5. Verify + Settle โ”‚
โ”‚ โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ 6. Confirmed โ”‚
โ”‚ โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ 7. 200 OK + Data โ”‚ โ”‚
โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ โ”‚
โ”‚ โ”‚ โ”‚

Data Sourcesโ€‹

The API aggregates data from multiple sources with automatic fallbacks:

CategoryPrimary SourceFallbacks
PricesDefiLlamaCoinGecko, CoinCap, CoinPaprika
ENSENS SubgraphDirect RPC
FarcasterNeynarโ€”
DeFiDefiLlamaโ€”
WalletAlchemyEtherscan

Cachingโ€‹

Responses are cached based on data volatility:

Data TypeCache TTL
Prices30 seconds
Gas15 seconds
ENS records5 minutes
DeFi TVL5 minutes
Fear & Greed1 hour

Rate Limitingโ€‹

TierDaily LimitPer Minute
Anonymous10030
SIWE20060
API Key50030

Next Stepsโ€‹