Skip to main content
Sepolia Testnet Only — All data is from Ethereum Sepolia. Token balances and positions have no real-world value. Write payments use Sepolia USDC.

What is x402?

The x402 protocol enables HTTP-native micropayments using the 402 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
Base URL: https://x402.nilemarkets.com

Free Endpoints (14 GET)

Pool and Protocol

Positions

Oracle and Pricing

Accounts and Fees

Token and Simulation

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

Without payment, the server returns 402 Payment Required with x402 payment requirements:
To complete the payment, use an x402-compatible client library that handles the 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).
x402 client libraries (available at x402.org) handle steps 2 through 4 automatically.

Rate Limits

MCP vs x402

The MCP server and x402 API expose the same 22 operations with identical data. Choose based on your client: