Base URL: /api
JSON everywhere. Content-Type: application/json
On purchase/activation, expect HTTP 402 with Solana Pay details.
Server-Sent Events for live portfolio updates: /events?wallet=
Fetch example
fetch('/api/x4a-data') .then(r => r.json()) .then(d => console.log('Price USD:', d.token.usdPrice));GET /api/x4a-data — price, mcap, liquidity, holders, txns
POST /api/grok — { id, type, query } ⇒ Grok-like insights
POST /api/buy-agent — triggers HTTP 402 Solana Pay flow
GET /api/candles?symbol=BTCUSDT&interval=1m
GET /api/trades?symbol=BTCUSDT
GET /events?wallet=
— SSE stream
X402 Protocol (Payments & PDA)
POST /api/x402/test — simulate payment
POST /api/x402/validate — validate receipt/signature
GET /api/x402/pda/escrow — escrow balance check
GET /api/x4a/swarm/status — counts/status
POST /api/x4a/evolution/sim — merge/fork simulation
POST /api/x402/bridge/cross — LayerZero/CCIP test
const r = await fetch('/api/buy-agent', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ walletAddress: '<yourWallet>', agentId: 'X4A' }) }); if (r.status === 402) { const info = await r.json(); // contains tx or Solana Pay URL // handle signing & submission here... }// GET /api/portfolio?wallet=Fg6PaF...sLnS // POST /api/order { wallet, symbol, side: "buy"|"sell", qty }// GET /events?wallet=<address> // Messages: { type: "snapshot" | "trade", data: ... }Public read endpoints do not require keys
Activation/payment endpoints respond with HTTP 402
Respect rate limits; cache token metrics for 10–30s
Use SSE instead of polling for portfolio updates
On 402, surface a clean Solana Pay UX and retry on nonce errors

