Multi-DEX Aggregation
Volume-weighted prices from Uniswap V3, SushiSwap, Curve, BaseSwap, Aerodrome, PancakeSwap, Balancer, and Camelot.
Real-time prices, funding rates, liquidation data, and risk metrics from 8+ DEXes and major CEXes. Pay per request with USDC on Base via x402 protocol.
Get started in under 5 minutes. Install the x402 SDK and start fetching aggregated market data.
// Install: npm install @x402/fetch viem
import { wrapFetchWithPayments } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";
import { createWalletClient, http } from "viem";
import { base } from "viem/chains";
// 1. Setup wallet on Base network
const account = privateKeyToAccount("0x_your_private_key");
const walletClient = createWalletClient({
account,
chain: base,
transport: http("https://mainnet.base.org"),
});
// 2. Create payment-enabled fetch
const fetchWithPayment = wrapFetchWithPayments(fetch, {
client: walletClient,
});
// 3. Fetch real-time ETH price ($0.01 USDC)
const response = await fetchWithPayment(
"https://api.foursec.xyz/price/ETH"
);
const data = await response.json();
console.log(`ETH: $${data.price_usd}`); // ETH: $2450.32# Step 1: Make request (returns 402 Payment Required)
curl -i https://api.foursec.xyz/price/ETH
# Step 2: Use x402 CLI for automatic payment
npx x402-cli fetch \
https://api.foursec.xyz/price/ETH \
--key 0x_your_private_key
# Step 3: Get response with aggregated data
# {"symbol":"ETH","price_usd":2450.32,"sources":3,...}# Install: pip install httpx web3 eth-account
import httpx
# Make request (see Python SDK for auto-payment)
response = httpx.get("https://api.foursec.xyz/price/ETH")
# Handle 402 payment flow
if response.status_code == 402:
payment_header = response.headers.get("x-payment")
# Sign USDC transfer and retry
# See: /integration/python for full guide
pass
# For simpler flow, use JavaScript SDK{
"symbol": "ETH",
"price_usd": 2450.32,
"change_24h": 2.45,
"volume_24h_usd": 12500000,
"total_sources": 3,
"spread": 0.07,
"sources": [
{
"dex": "Uniswap V3",
"price": 2450.30,
"liquidity_usd": 5200000
},
{
"dex": "BaseSwap",
"price": 2450.35,
"liquidity_usd": 3100000
},
{
"dex": "SushiSwap",
"price": 2450.28,
"liquidity_usd": 4200000
}
]
}Pay-as-you-go with USDC on Base via the x402 protocol. No subscriptions, no commitments.
| Endpoint | Cost | Description |
|---|---|---|
GET /price/:symbol | $0.01 | Real-time aggregated price from 8+ DEXes |
GET /price/history/:symbol | $0.02 | Historical OHLCV candlestick data |
GET /volume/:symbol | $0.02 | 24h trading volume across all DEXes |
GET /spread/:pair | $0.02 | Bid/ask spread analysis |
GET /arbitrage-opportunity | $0.05 | Cross-DEX arbitrage scanner |
GET /volatility-index/:symbol | $0.03 | Risk metrics: VaR, Sharpe, volatility |
POST /price-alert | $0.04 | Create webhook price alert |
| Endpoint | Cost | Description |
|---|---|---|
GET /funding-rate/:symbol | $0.02 | Current perpetual funding rate with signal |
GET /funding-rate/history/:symbol | $0.03 | Historical funding rate data |
GET /funding-rate/extreme | $0.02 | Extreme funding rates scanner across markets |
| Endpoint | Cost | Description |
|---|---|---|
GET /liquidation/heatmap/:symbol | $0.05 | Liquidation heatmap with cascade risk levels |
GET /liquidation/recent | $0.03 | Recent liquidations with long/short breakdown |
POST /liquidation/alert | $0.06 | Create liquidation cascade alert webhook |
| Endpoint | Cost | Description |
|---|---|---|
GET /api/v1/prices | $0.005 | Batch CEX prices (e.g. ?symbols=btc,eth,sol) |
GET /api/v1/market/:id | $0.005 | Market details by CoinGecko ID |
GET /api/v1/market/:id/history | $0.01 | Historical market data from CEX |
| Endpoint | Cost | Description |
|---|---|---|
GET /health | Free | Health check |
GET /api/v1/status | Free | Detailed system status |
GET /price-alert/:id | Free | Check price alert status |
DELETE /price-alert/:id | Free | Cancel a price alert |
GET /price-alerts | Free | List all active price alerts |
GET /liquidation/alerts | Free | List all active liquidation alerts |
GET / | Free | API information and endpoint list |
GET /openapi.json | Free | OpenAPI specification |
GET /.well-known/x402.json | Free | x402 payment discovery |
Smart Caching = Cost Savings
All paid endpoints have a 30-second cache TTL. Identical requests within 30 seconds are free (served from cache). Use this aggressively to reduce costs by up to 70%.
We aggregate prices from 8+ major decentralized exchanges across multiple chains:
| DEX | Chains | Popular Pairs |
|---|---|---|
| Uniswap V3 | Base, Ethereum | ETH/USDC, BTC/USDC, USDC/USDT |
| SushiSwap | Base, Ethereum | ETH/USDC, ETH/USDT, LINK/ETH |
| Curve | Ethereum | 3pool, ETH/stETH, FRAX/USDC |
| BaseSwap | Base | ETH/USDC, BASE/ETH, USDbC/USDC |
| Aerodrome | Base | ETH/USDC, AERO/ETH, cbETH/ETH |
| PancakeSwap V3 | Base, BSC | ETH/USDC, BNB/USDC, CAKE/BNB |
| Balancer V2 | Ethereum | ETH/USDC, WBTC/ETH, BAL/ETH |
| Camelot | Arbitrum | ETH/USDC, ARB/ETH, GMX/ETH |
Single-DEX prices can be misleading. Here's why aggregation matters:
The x402 protocol enables seamless pay-per-request API access:
Client 4SEC API Base Network
| | |
|-- GET /price/ETH ------->| |
| | |
|<-- 402 Payment Required -| |
| (X-PAYMENT header) | |
| | |
|-- Sign USDC transfer ----------------------------->|
| | |
|-- GET + Payment Proof -->| |
| |-- Verify on-chain ------>|
| |<-- Confirmed ------------|
| | |
|<-- 200 OK + Data --------| |
| {"price_usd": 2450.32}| |
| | |
X-PAYMENT headerTotal Cost
Each /price/:symbol request costs just $0.01 USDC. Same request within 30s is free from cache.
Ready to integrate? Choose your path:
| Step | Resource | Time |
|---|---|---|
| 1 | Quick Start Guide | 5 minutes |
| 2 | Setup Your Wallet | 10 minutes |
| 3 | Explore API Reference | 15 minutes |
| 4 | Build Your Integration | 30 minutes |