Cover photo

X4A Autonomous Agents Market API

What this is

https://x4agent.io

Quickstart

  1. Base URL: /api

  2. JSON everywhere. Content-Type: application/json

  3. On purchase/activation, expect HTTP 402 with Solana Pay details.

  4. Server-Sent Events for live portfolio updates: /events?wallet=

  5. Fetch example

    fetch('/api/x4a-data')
      .then(r => r.json())
      .then(d => console.log('Price USD:', d.token.usdPrice));
    

    Core Endpoints

    Token & Agents

    • 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

    Market Data

    • GET /api/candles?symbol=BTCUSDT&interval=1m

    • GET /api/trades?symbol=BTCUSDT

    • GET /events?wallet=

       — SSE stream

    • X402 Protocol (Payments & PDA)

      https://x4agent.io

      Payments & Validation

      • POST /api/x402/test — simulate payment

      • POST /api/x402/validate — validate receipt/signature

      • GET /api/x402/pda/escrow — escrow balance check

      Swarm & Bridge

      • GET /api/x4a/swarm/status — counts/status

      • POST /api/x4a/evolution/sim — merge/fork simulation

      • POST /api/x402/bridge/cross — LayerZero/CCIP test

      Example: HTTP 402 flow

      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...
      }
      

      Perp Simulator (Under the Dev Tools)

      https://x4agent.io

      Portfolio & Orders

      // GET /api/portfolio?wallet=Fg6PaF...sLnS
      // POST /api/order { wallet, symbol, side: "buy"|"sell", qty }
      

      Real-time

      // GET /events?wallet=<address>
      // Messages: { type: "snapshot" | "trade", data: ... }
      

      Authentication & Usage

      Who is this for?

      https://x4agent.io

      • Public read endpoints do not require keys

      • Activation/payment endpoints respond with HTTP 402

      Best Practices

      • 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

      https://github.com/x4a-core