How to Use x402.tunedfor.ai
Integration Guide

Step-by-step integration reference. Covers the x402 payment protocol, Python SDK setup, endpoint reference, response schemas, MCP server configuration, and agent discovery metadata.

What This Is

x402.tunedfor.ai is a pay-per-call REST API that delivers structured crypto market data to AI agents. Each HTTP call is paid in USDC on Base or Solana via the x402 protocol — no API keys, no accounts, no subscription required.

The server returns a 402 Payment Required response. The agent's x402 SDK client handles USDC settlement automatically (~200ms via Coinbase CDP) and retries the request with a payment header attached.

Responses are structured JSON your code can branch on directly. Fields like stance, orderflow_signal, and cvd_direction are enumerated strings — not prose summaries that require further parsing.

Prerequisites

Need USDC on Base? Bridge at bridge.base.org or buy directly via Coinbase. Network ID for Base mainnet: eip155:8453.

Quick Start: Python SDK

The x402 Python client handles the full payment lifecycle. Your code calls the endpoint once — the SDK intercepts the 402, settles payment, and returns the data transparently.

Python
import os
import asyncio
from x402.http.clients.httpx import x402HttpxClient
from x402.mechanisms.evm.signers import EthAccountSigner

signer = EthAccountSigner(private_key=os.environ["WALLET_PRIVATE_KEY"])
client = x402HttpxClient(signer=signer)

async def main():
    # Call any endpoint — payment handled automatically
    resp = await client.post(
        "https://x402.tunedfor.ai/analyze/orderflow",
        json={"token": "BTC"}
    )
    data = resp.json()
    print(f"CVD direction: {data['cvd_direction']}")
    print(f"Buy ratio: {data['buy_ratio']}")
    print(f"Exchanges accumulating: {data['exchange_breakdown']['exchanges_accumulating']}/20")

asyncio.run(main())

Install dependencies:

bash
pip install "x402[httpx,evm]" eth-account

Set the WALLET_PRIVATE_KEY environment variable to your EVM private key (Base mainnet). Never hardcode keys or commit them to source control.

How x402 Payment Works

The x402 protocol is an HTTP extension that allows agents to pay per API call with on-chain USDC. The flow is fully automatic when using the SDK.

  1. Agent POSTs to any paid endpoint. No auth header needed.
  2. Server returns HTTP 402 Payment Required with a payment-required header containing the price (USDC amount), receiving wallet address, and network.
  3. The x402 SDK reads the header, signs a USDC transfer from the agent's wallet, and sends the payment to the Coinbase CDP facilitator.
  4. CDP confirms settlement (~200ms).
  5. Agent retries the original request with an X-Payment header attached.
  6. Server verifies payment and returns the data with HTTP 200.

No subscription. No minimum spend. Each call is independent. If payment verification fails, the server returns 402 again — no funds are deducted for failed settlements.

No SDK? You can send the X-Payment header manually — see x402.org for the full protocol spec. The SDK is the recommended path for production agents.

Endpoint Reference

All paid endpoints require a valid x402 payment. Free endpoints return immediately with no payment flow.

Endpoint Price Description Tokens
POST /data $0.20 Live snapshot: price, volume, derivatives, orderflow, sentiment 15
POST /analyze/market $0.25 Directional reading + macro regime. Data-only, no LLM processing. 15
POST /analyze/orderflow $0.50 Cross-exchange CVD, whale activity, liquidation pressure, exchange breakdown 24
POST /analyze/full $0.75 All data + LLM synthesis: stance, orderflow signal, risk level, verdict 15
POST /analyze/address $0.25 On-chain address risk profile. EVM + Solana. Auto-detects chain. Any
POST /data/history/1h $5.00 Hourly OHLCV + orderflow bars. Up to 7 years of history. 24
POST /data/history/1d $5.00 Daily OHLCV + orderflow bars. Up to 7 years of history. 24
POST /data/history/5m $1.00 5-minute bars. 17-day rolling window. 24
GET /demo FREE Cached BTC response from each paid endpoint
GET /catalog FREE Machine-readable endpoint listing with schemas and pricing
GET /coverage FREE Data inventory: every token, every timeframe, historical depth

Request Format

All paid endpoints accept a JSON POST body. Only token is required:

JSON — minimal
{"token": "BTC"}

Optional parameters:

JSON — with options
{
  "token": "ETH",
  "context": "7d",
  "max_age_seconds": 300
}
context "7d" or "30d" — adds historical percentile rankings to the response. Omit for a plain snapshot.
max_age_seconds Freshness contract. Reject cached responses older than N seconds. Pass 0 to force a live fetch. Default: server cache TTL (1 hour).

History endpoint parameters

History endpoints (/data/history/1h, /data/history/1d, /data/history/5m) also accept start, end, and limit:

JSON — history request
{
  "token": "BTC",
  "start": "2022-01-01",
  "end": "2022-12-31",
  "limit": 5000
}

Maximum 5,000 bars per call. For /data/history/5m the window is limited to the last 17 days; start and end will be clamped to that range.

Response: /analyze/orderflow

Aggregates live orderflow from 20 exchanges. CVD, buy/sell pressure, whale bars, liquidation data, and a per-exchange breakdown. Data sourced from aggr-server, refreshed every 5 minutes.

JSON — example response
{
  "token": "BTC",
  "timestamp": "2026-04-10T14:22:00Z",
  "cvd_direction": "up",
  "cvd_value": 14523.7,
  "buy_ratio": 0.61,
  "whale_bar_count_1h": 3,
  "liquidation_buy_1h": 12400.0,
  "liquidation_sell_1h": 89200.0,
  "cvd_divergence": 0.14,
  "spot_perp_delta": 0.03,
  "volume_herfindahl": 0.22,
  "exchange_breakdown": {
    "exchanges_accumulating": 14,
    "exchanges_distributing": 6,
    "exchanges_total": 20,
    "dominant_direction": "buy",
    "diverging_exchanges": []
  },
  "data_freshness": {
    "data_age_seconds": 120,
    "stale": false
  }
}

Key fields explained

volume_herfindahl Volume concentration index (0–1). Values above 0.6 indicate volume is concentrated on one exchange — elevated manipulation risk.
cvd_divergence Spot CVD minus perp CVD, normalized. Positive values mean spot buyers are leading perp — a leading bullish indicator.
exchange_breakdown.exchanges_accumulating How many of the 20 monitored venues are net buying over the measurement window. Use as a breadth indicator.
liquidation_sell_1h USD value of long liquidations in the past hour. Large values can indicate cascading deleveraging.
data_freshness.data_age_seconds How old the underlying snapshot is. Every response carries this field — use it to detect stale cache hits.

Response: /analyze/full

Combines all market and orderflow data, then runs a single LLM synthesis pass. Returns enumerated classification fields you can branch on directly, plus a one-sentence verdict that cites specific data values.

JSON — example response
{
  "token": "BTC",
  "stance": "BULLISH",
  "orderflow_signal": "ACCUMULATION",
  "risk_level": "LOW",
  "verdict": "Market stance BULLISH with signal_confidence 0.72. Orderflow ACCUMULATION across 14/20 exchanges. Risk LOW — funding_rate 0.0045 within normal range.",
  "warnings": [],
  "cvd_direction": "up",
  "buy_ratio": 0.61,
  "macro_regime": "risk_on",
  "data_freshness": {"data_age_seconds": 180, "stale": false}
}

Enumerated fields — branch on these

stance BULLISH | BEARISH | NEUTRAL
orderflow_signal ACCUMULATION | DISTRIBUTION | NEUTRAL
risk_level LOW | MODERATE | HIGH | CRITICAL
macro_regime risk_on | risk_off | bull | bear | choppy
warnings Array of strings. Empty when no anomalies detected. May flag stale data, extreme funding rates, or diverging exchanges.

MCP Server (Claude Desktop / Cursor)

An MCP server wraps the x402.tunedfor.ai endpoints as callable tools for Claude Desktop, Cursor, and any other MCP-compatible host. Payment is handled transparently by the server process.

Install

bash
pip install "x402[httpx,evm]" mcp eth-account

Claude Desktop configuration

Edit %APPDATA%\Claude\claude_desktop_config.json on Windows (or ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

JSON — claude_desktop_config.json
{
  "mcpServers": {
    "x402-crypto": {
      "command": "python",
      "args": ["/path/to/x402/mcp_server.py"],
      "env": {
        "X402_API_BASE_URL": "https://x402.tunedfor.ai",
        "PAYER_PRIVATE_KEY": "0x_YOUR_FUNDED_WALLET_KEY",
        "PAYER_NETWORK": "eip155:8453"
      }
    }
  }
}

Restart Claude Desktop after saving the config. The x402 crypto market data tools will appear in the tool selector automatically. The MCP server process holds the wallet key and handles payment signing — Claude itself never sees the private key.

Security: Never paste your private key directly into a prompt or conversation. Pass it only via environment variables to the MCP server process.

Supported Tokens

15 tokens — /data, /analyze/market, /analyze/full

BTC ETH SOL XRP ADA DOGE AVAX LINK BNB ATOM DOT ARB SUI OP LTC

24 tokens — /analyze/orderflow, /data/history/*

All 15 above, plus:

NEAR TRX BCH SHIB HBAR TON XLM UNI AAVE

Use GET /coverage to see per-token historical depth and exchange coverage before calling paid endpoints.

Free Endpoints

These endpoints return immediately with no payment required. Use them to preview output, discover available data, and check service health before spending USDC.

bash — curl
# Cached BTC responses from all paid endpoints
curl https://x402.tunedfor.ai/demo

# Machine-readable endpoint listing with schemas and pricing
curl https://x402.tunedfor.ai/catalog

# Data inventory — every token, every timeframe, historical depth and bar counts
curl https://x402.tunedfor.ai/coverage

# Service health
curl https://x402.tunedfor.ai/health

The /demo endpoint is useful for validating response parsing before a paid call. The /catalog endpoint is machine-readable JSON — agents can query it to enumerate available endpoints, prices, and request/response schemas at runtime.

Discovery

x402.tunedfor.ai is discoverable by AI agents and crawlers via standard discovery files. Agents that implement the x402 protocol or A2A spec can find this service automatically.

GET /llms.txt Agent-readable service description. Lists all endpoints, pricing, and token coverage in plain text.
GET /.well-known/x402.json x402 protocol manifest. Describes payment networks, facilitator, and supported endpoint paths.
GET /.well-known/agent-card.json Google Agent-to-Agent (A2A) discovery card. Used by A2A-compatible orchestrators to find and invoke this service.
Coinbase Bazaar Auto-indexed on first CDP settlement. Agents using the CDP facilitator discover x402.tunedfor.ai through the Bazaar registry.
Smithery Listed at smithery.ai/server/x402-crypto-market-structure for MCP-compatible agent discovery.