What is x402?
The x402 protocol enables HTTP-native micropayments using the402 Payment Required status code. When you call a paid endpoint without payment, the server returns a 402 response with payment requirements. Your client pays the specified amount (onchain USDC transfer), attaches the payment proof to a retry, and the server fulfills the request.
The Nile Markets x402 API splits access into two tiers:
- Read endpoints (GET) — Free, no payment required
- Write endpoints (POST) — $0.01 USDC per request via x402
https://x402.nilemarkets.com
Free Endpoints (14 GET)
Pool and Protocol
Positions
Oracle and Pricing
Accounts and Fees
Token and Simulation
Paid Endpoints (8 POST)
Each POST request costs $0.01 USDC on Sepolia, paid via the x402 protocol. The payment is a separate onchain USDC transfer to the configured payee address, verified by an x402 facilitator before the request is fulfilled.Trading
Margin
Vault (Liquidity Providers)
Token Approval and Testnet
All amounts are strings in USDC smallest unit (6 decimals).
"1000000000" = 1,000 USDC.
Response Format
Every response uses a standard JSON envelope:
Write endpoints return
TransactionCalldata in the data field, identical to the MCP server format.
Examples
Free Read — Pool State
Free Read — Forward Price
Paid Write — Open Position
Without payment, the server returns402 Payment Required with x402 payment requirements:
402 → pay → retry flow automatically. See x402.org for client SDKs in TypeScript, Python, and Go.
x402 Payment Flow
1
Initial request
Your client sends a POST to a paid endpoint without payment headers.
2
402 response
The server returns HTTP 402 with
accepts containing the payment scheme, amount ($0.01 USDC), network, and payee address.3
Onchain payment
Your client transfers the specified USDC amount to the payee address on Sepolia and obtains a payment proof.
4
Retry with proof
Your client retries the original request with the
X-PAYMENT header containing the payment proof.5
Fulfillment
The server verifies the payment via the x402 facilitator and returns the requested data (unsigned transaction calldata for write endpoints).