CRYPTO MARKET DATA API
Real-time
Multi-DEX
Aggregated Prices
Access aggregated prices, arbitrage opportunities, and risk metrics from 8+ DEXes. Pay per request with USDC on Base via x402 protocol.
FEATURES
Everything you need for crypto data
Multi-DEX Aggregation
Volume-weighted prices from Uniswap, SushiSwap, Curve, BaseSwap, Aerodrome, and 3 more DEXes.
Arbitrage Detection
Real-time cross-DEX arbitrage opportunities with profit calculations and gas estimates.
Risk Metrics
Volatility, VaR, Sharpe ratio, and sentiment analysis for informed trading decisions.
Real-time Data
30-second cache TTL, 100 req/min rate limit. Fresh data for high-frequency trading.
Historical OHLCV
Candlestick data with 1m, 5m, 1h, 1d intervals. Up to 1 year history.
Price Alerts
Webhook notifications when price hits your target. Perfect for trading bots.
ENDPOINTS & PRICING
Pay-as-you-go with x402
No subscriptions, no API keys. Pay per request with USDC on Base. Same request within 30s is free (cached).
| Endpoint | Price | Description |
|---|---|---|
| GET /price/:symbol | $0.01 | Real-time aggregated price from 8+ DEXes |
| GET /volume/:symbol | $0.02 | 24h trading volume across all DEXes |
| GET /spread/:pair | $0.02 | Bid/ask spread analysis |
| GET /price/history/:symbol | $0.02 | Historical OHLCV candlestick data |
| GET /volatility-index/:symbol | $0.03 | Risk metrics — VaR, Sharpe, volatility |
| POST /price-alert | $0.04 | Create webhook price alert |
| GET /arbitrage-opportunity | $0.05 | Cross-DEX arbitrage scanner |
| GET /api/v1/prices?symbols=btc,eth | $0.005 | CEX prices from Binance/CoinGecko |
| GET /api/v1/market/:id | $0.005 | Market details |
| GET /api/v1/market/:id/history | $0.01 | Historical market data |
| GET /api/v1/status | FREE | Detailed system status |
| GET /price-alert/:id | FREE | Check alert status |
| DELETE /price-alert/:id | FREE | Cancel alert |
| GET /health | FREE | Health check |
| GET / | FREE | API info & available endpoints |
USDC on Base
Chain ID 8453
30s Free Cache
Same request = no charge
No API Key
Just your wallet
INTEGRATION
Get started in 5 minutes
// 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";
// Setup wallet on Base
const account = privateKeyToAccount("0x...");
const walletClient = createWalletClient({
account,
chain: base,
transport: http("https://mainnet.base.org"),
});
// Create payment-enabled fetch
const fetchWithPayment = wrapFetchWithPayments(fetch, {
client: walletClient,
});
// Make request (auto-payment!)
const res = await fetchWithPayment(
"https://api.foursec.xyz/price/ETH"
);
const data = await res.json();
console.log(`ETH: $${data.price_usd}`);# Step 1: Initial request returns 402
curl -i https://api.foursec.xyz/price/ETH
# Response: 402 Payment Required
# X-PAYMENT: {"scheme":"exact-evm",...}
# Step 2: Use x402 CLI for auto-payment
npx x402-cli fetch \
https://api.foursec.xyz/price/ETH \
--key 0x_your_private_key
# Step 3: Response with data
# {"symbol":"ETH","price_usd":2450.32,...}# Install: pip install httpx web3 eth-account
import httpx
# Step 1: Get payment requirements
resp = httpx.get("https://api.foursec.xyz/price/ETH")
# Returns 402 with X-PAYMENT header
payment = resp.headers.get("x-payment")
# Step 2: Sign USDC transfer on Base
# Step 3: Retry with payment proof
# (Use JavaScript SDK for simpler flow)
# Recommended: Use the JavaScript SDK
# which handles everything automaticallyHow x402 Works
- 1
Request data
Your app calls the API endpoint
- 2
402 Payment Required
API returns payment details in X-PAYMENT header
- 3
Sign USDC transfer
SDK signs payment from your wallet on Base
- 4
Retry with proof
Client retries request with payment proof
- 5
Data returned
API verifies payment and returns data. Cost: $0.01
💡 Pro tip:The @x402/fetch SDK handles all payment logic automatically. Just call fetchWithPayment(url) and it works!
BY THE NUMBERS
Built for performance
15
API Endpoints
8+
DEX Sources
<100ms
Avg Latency
30s
Cache TTL
Ready to get started?
Start using 4SEC API today. No credit card, no signup form. Just connect your wallet and pay as you go.
✓ No API key required
✓ Pay with USDC on Base
✓ 30s free cache window