x402-protected API endpoints for AI agents. Get best-price quotes aggregated across Aerodrome, Uniswap V3, and PancakeSwap in a single call. Pay per request with USDC on Base.
Connect to Claude Desktop, Cursor, or any MCP client for tool-use access to all endpoints.
{
"mcpServers": {
"base-alpha": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-remote@latest",
"https://base-alpha.xyz/api/mcp"]
}
}
}Uses playground endpoints (no x402 payment) for read-only tools. See llms.txt and openapi.json for full API spec.
Try endpoints directly — live data, no payment required
Select an endpoint and click "Try It" to see live results
# Step 1: Get 402 response with payment requirements curl -s https://base-alpha.xyz/api/agent/quote\ ?tokenIn=0x4200000000000000000000000000000000000006\ &tokenOut=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\ &amountIn=1000000000000000000 # Step 2: Pay with x402 header (after signing) curl -s -H "X-PAYMENT: <base64-payment-header>" \ https://base-alpha.xyz/api/agent/quote\ ?tokenIn=0x4200000000000000000000000000000000000006\ &tokenOut=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\ &amountIn=1000000000000000000
import { createPaymentHeader } from "x402/client";
import { createSigner } from "x402/types";
const signer = createSigner(walletClient);
const url = "https://base-alpha.xyz/api/agent/quote"
+ "?tokenIn=0x4200000000000000000000000000000000000006"
+ "&tokenOut=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
+ "&amountIn=1000000000000000000";
// First call returns 402 with payment requirements
const res = await fetch(url);
const { accepts } = await res.json();
// Sign and pay
const header = await createPaymentHeader(signer, 1, accepts[0]);
const paidRes = await fetch(url, {
headers: { "X-PAYMENT": header }
});
const quote = await paidRes.json();
console.log(quote);
// { amountOut: "3215000000", dexName: "Aerodrome", ... }| Status | Error | Retry? | Strategy |
|---|---|---|---|
| 400 | Invalid params | No | Fix request parameters |
| 402 | Payment required | Yes | Sign x402 payment header |
| 402 | Payment failed | Yes | Re-sign with fresh nonce |
| 404 | No liquidity | No | Try a different token pair |
| 500 | Internal error | Yes | Exponential backoff 1s/2s/4s |
async function fetchWithRetry(url: string, opts?: RequestInit, retries = 3) {
for (let i = 0; i < retries; i++) {
const res = await fetch(url, opts);
if (res.ok) return res.json();
const body = await res.json().catch(() => ({}));
const retryable = res.status === 402 || res.status >= 500;
if (!retryable || i === retries - 1) {
throw new Error(body.error ?? `HTTP ${res.status}`);
}
await new Promise((r) => setTimeout(r, 1000 * 2 ** i));
}
}Copy-paste recipes to get started
Poll prices and alert on threshold cross
read-onlyimport { fetchWithRetry } from "./retry";
const WETH = "0x4200000000000000000000000000000000000006";
const THRESHOLD_USD = 3000;
async function monitorPrice(intervalMs = 30_000) {
while (true) {
const data = await fetchWithRetry(
`https://base-alpha.xyz/api/agent/prices?tokens=${WETH}`
);
const price = parseFloat(data.prices?.[WETH]?.usd ?? "0");
console.log(`WETH: $${price.toFixed(2)}`);
if (price >= THRESHOLD_USD) {
console.log("ALERT: WETH crossed $" + THRESHOLD_USD);
// send notification...
}
await new Promise((r) => setTimeout(r, intervalMs));
}
}
monitorPrice();