Skip to content

Pay per call with x402

View as Markdown

An AI agent with a wallet can pay for each call with x402: the API answers 402 Payment Required with the price, the agent pays in USDC on Base, and repeats the request. No account and no API key. Calls for the demo companies (AAPL, MSFT, JPM, KO, XOM, NVDA, AMZN, GOOGL, TSLA and LLY) are free with no key and no payment, up to 60 an hour per network. Form 13F holdings by manager are charged even for those companies.

Dataset Route Price per call
Company profile API /v1/companies/{id} $0.006
Key metrics API /v1/companies/{id}/metrics $0.006
Financial statements fields API /v1/companies/{id}/financials $0.006
SEC financial statements API /v1/companies/{id}/statements $0.018
Segment revenue API /v1/companies/{id}/segments $0.018
Insider trades (Form 4) API /v1/companies/{id}/insider-trades $0.018
Form 13F holdings API /v1/companies/{id}/form13f $0.018
Institutional holders (13F) API /v1/companies/{id}/holders $0.018
Beneficial ownership (13D/13G) API /v1/companies/{id}/ownership $0.018
SEC filings list API /v1/companies/{id}/filings $0.018
Earnings releases API /v1/companies/{id}/earnings-releases
/v1/companies/{id}/earnings-releases/{accession}
$0.018 or $0.03
US macro data API /v1/macro/{series} $0.006

Listed in Coinbase’s x402 Bazaar and on x402scan. Machine-readable: OpenAPI and /.well-known/x402.

Any x402 client works. These examples use Coinbase’s x402 libraries. The wallet needs USDC on Base; no ETH is needed. Keep its private key in an environment variable, never in code.

JavaScript or TypeScript (npm install @x402/fetch @x402/evm viem):

import { wrapFetchWithPayment, x402Client } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm/exact/client';
import { privateKeyToAccount } from 'viem/accounts';
const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
client.register('eip155:8453', new ExactEvmScheme(account));
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const res = await fetchWithPayment('https://api.belfortagent.xyz/v1/companies/META/metrics?metric=revenue&frequency=annual');
console.log(await res.json());

Python (pip install "x402[all]" eth-account requests):

import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm.exact.register import register_exact_evm_client
from x402.mechanisms.evm.signers import EthAccountSigner
client = x402ClientSync()
register_exact_evm_client(client, EthAccountSigner(Account.from_key(os.environ["WALLET_PRIVATE_KEY"])))
session = x402_requests(client)
print(session.get("https://api.belfortagent.xyz/v1/companies/META/metrics?metric=revenue&frequency=annual").json())

Each call pays its listed price once. A call that returns no records, or an error, is not charged.