Overview
x402 is an open payment protocol. A client pays for each HTTP request with USDC on Base. No API key or account is required. Requests that include anX-API-KEY header are billed to that account as usual. x402 applies only to requests without a key.
How it works
- The client calls an endpoint with no
X-API-KEYheader. - The API returns
402 Payment Required. ThePAYMENT-REQUIREDheader contains the payment terms: the amount, the USDC contract on Base, and the receiving address. - The client signs a USDC transfer authorization for that amount and retries the request with a
PAYMENT-SIGNATUREheader. - The API verifies the signature with the payment facilitator, returns the data, and settles the payment on-chain. The response includes a
PAYMENT-RESPONSEheader with the transaction hash.
Supported endpoints
Parameters and response formats are the same as with an API key. All other endpoints require an API key.
Requirements
- A wallet on Base whose private key the client holds. The client signs each payment locally.
- USDC on Base in that wallet.
- No ETH is needed. The facilitator pays the gas.
Example
Payment terms
ThePAYMENT-REQUIRED header is base64-encoded JSON:
Read the amount from the header on each request.
Receipts
Every paid200 response includes a PAYMENT-RESPONSE header. It is base64-encoded JSON with success, network, payer, and transaction (the on-chain transaction hash).
Limits
- History. x402 requests return data from the last 365 days. A request for older data only returns
403with the window start date. Full history requires an API key. - Rate limit. 10,000 requests per minute per wallet.
- Pagination.
next_page_urlworks the same as with an API key. Each page is a separate paid request. - Settlement. Payment is settled only after a successful response. Error responses are not charged.
- License. Data accessed with x402 is for Non-Professional use. Professional use requires a plan at financialdatasets.ai.
Errors
Payment errors return402 with a JSON body. The error field identifies the cause.
A
503 with a Retry-After header means the facilitator is temporarily unavailable. Retry after the given interval.
Related
Agent Onboarding
Create an API key programmatically for endpoints and history not covered by x402.
Endpoint map
Every endpoint with parameters, in llms.txt form.
Announcement
Introducing x402 payments on the Financial Datasets blog.