These endpoints are pay-per-use and intended for AI agents and experimental use
cases. Features and pricing may change. For production workloads, we recommend
the standard API key authentication flow.
x402 Overview
x402 is an open payment protocol developed by Coinbase that uses HTTP402 Payment Required responses to charge for
individual API calls with instant stablecoin payments. Instead of signing
up for an account and managing an API key, agents pay in USDC per request
directly from a wallet.
CoinStats exposes a pay-per-use surface covering every read-only endpoint
in the CoinStats Public API — live coin prices, market data, news,
insights, wallet balances and DeFi positions, plus shared portfolio reads.
How It Works
Every request to a protected endpoint follows the same three-step flow:1
Request the endpoint
Send a normal
GET request. Because no payment is attached, the
gateway responds with HTTP 402 Payment Required — the response
includes the required amount, currency, wallet address, and network.2
Sign a USDC payment authorization
Your wallet signs an EIP-3009
transferWithAuthorization for the
exact amount. The @x402/fetch
client library handles this automatically; custom clients can sign
with any EIP-712-compatible wallet.3
Retry with the payment header
Send the same request again, this time with the
X-PAYMENT header
containing the signed authorization. The facilitator settles on
chain and the gateway returns the data with an X-PAYMENT-RESPONSE
receipt. A Set-Cookie: auth_token=... header is also issued —
subsequent calls within one hour skip the facilitator entirely.Authentication
No API key is needed. Point your client at the dedicated x402 subdomain and skip thex-api-key header:
https://api.coinstats.app/v1 under the
supported list below is gated by x402 at https://x402.coinstats.app.
Supported Endpoints
Every listed endpoint is a read-onlyGET. Prices are quoted in USDC
and settle on Base mainnet (chain ID 8453).
Endpoints marked with
sharetoken require a sharetoken header —
the CoinStats user shares a portfolio link from the mobile app and
hands the token to the agent. See shareToken for how
to obtain one.
Pricing & Payment Method
Pricing is tiered by the underlying data cost. Simple lookups (coin
price, markets, news) are 0.004.
Heavy DeFi/portfolio aggregations are 0.05.
Request Example
Node.js — @x402/fetch
auth_token cookie and skip the
facilitator round-trip.
cURL — manual
The402 challenge is returned in the payment-required response
header (base64-encoded JSON). To settle manually you’d need to sign an
EIP-3009 authorization and replay the request with X-PAYMENT. For
any real workload, use the @x402/fetch client library above.
Response Example
X-PAYMENT-RESPONSE header on a 200 contains the settlement
receipt (transaction hash + facilitator ack) for record-keeping.
Discovery
CoinStats endpoints are discoverable by agents via two indexes:- CDP Bazaar — every
paid call is indexed under
https://api.cdp.coinbase.com/platform/v2/x402/discovery/resourceswith full-text searchable descriptions and input/output schemas. - agentic.market — surfaces CoinStats in its AI-agent marketplace alongside other x402-enabled data services.
Further Reading
- x402 protocol site — spec, reference clients, ecosystem
- CDP x402 Quickstart
- Cloudflare’s x402 integration post
- CoinStats Public API reference — detailed schemas for every endpoint