Skip to main content

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 an X-API-KEY header are billed to that account as usual. x402 applies only to requests without a key.

How it works

  1. The client calls an endpoint with no X-API-KEY header.
  2. The API returns 402 Payment Required. The PAYMENT-REQUIRED header contains the payment terms: the amount, the USDC contract on Base, and the receiving address.
  3. The client signs a USDC transfer authorization for that amount and retries the request with a PAYMENT-SIGNATURE header.
  4. The API verifies the signature with the payment facilitator, returns the data, and settles the payment on-chain. The response includes a PAYMENT-RESPONSE header with the transaction hash.
The x402 client libraries handle steps 2 to 4.

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

The PAYMENT-REQUIRED header is base64-encoded JSON:
Read the amount from the header on each request.

Receipts

Every paid 200 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 403 with the window start date. Full history requires an API key.
  • Rate limit. 10,000 requests per minute per wallet.
  • Pagination. next_page_url works 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 return 402 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.

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.