Appearance
cURL Examples
Free Endpoints (No Payment)
Health Check
curl -s https://api.foursec.xyz/health | jq
List Endpoints
curl -s https://api.foursec.xyz/ | jq
OpenAPI Specification
curl -s https://api.foursec.xyz/openapi.json | jq
x402 Payment Discovery
curl -s https://api.foursec.xyz/.well-known/x402.json | jq
Using x402 CLI (Recommended)
Install CLI
npm install -g @x402/cli
DEX Endpoints
# Get Price ($0.01)
x402 get https://api.foursec.xyz/price/ETH --wallet 0x_your_key
# Get Volume ($0.02)
x402 get https://api.foursec.xyz/volume/ETH --wallet 0x_your_key
# Get Spread ($0.02)
x402 get https://api.foursec.xyz/spread/ETH/USDC --wallet 0x_your_key
# Get Historical Data ($0.02)
x402 get "https://api.foursec.xyz/price/history/ETH?interval=1h&limit=24" --wallet 0x_your_key
# Get Volatility ($0.03)
x402 get https://api.foursec.xyz/volatility-index/ETH --wallet 0x_your_key
# Get Arbitrage ($0.05)
x402 get https://api.foursec.xyz/arbitrage-opportunity --wallet 0x_your_key
Funding Rate Endpoints
# Current funding rate ($0.03)
x402 get https://api.foursec.xyz/funding-rate/ETH --wallet 0x_your_key
# Historical funding rates ($0.04)
x402 get "https://api.foursec.xyz/funding-rate/history/ETH?limit=100" --wallet 0x_your_key
# Extreme funding rates ($0.05)
x402 get https://api.foursec.xyz/funding-rate/extreme --wallet 0x_your_key
Liquidation Endpoints
# Liquidation heatmap ($0.04)
x402 get https://api.foursec.xyz/liquidation/heatmap/ETH --wallet 0x_your_key
# Recent liquidations ($0.03)
x402 get https://api.foursec.xyz/liquidation/recent --wallet 0x_your_key
# Liquidation alert ($0.06)
x402 get https://api.foursec.xyz/liquidation/alert --wallet 0x_your_key
CEX Market Data
# Aggregated CEX prices ($0.02)
x402 get "https://api.foursec.xyz/api/v1/prices?symbols=btc,eth,sol" --wallet 0x_your_key
# CEX market details ($0.03)
x402 get https://api.foursec.xyz/api/v1/market/bitcoin --wallet 0x_your_key
# CEX market history ($0.04)
x402 get "https://api.foursec.xyz/api/v1/market/bitcoin/history?days=7" --wallet 0x_your_key
Manual cURL (Advanced)
Step 1: Get Payment Requirements
curl -i https://api.foursec.xyz/price/ETH
# Returns: HTTP 402
# Header: X-PAYMENT-REQUIRED with encoded payment details
# Body: {"error":"payment_required","amount":"0.01","token":"USDC","network":"base"}
Step 2: Sign Payment
You need to sign an EIP-712 typed data with your wallet key authorizing the USDC transfer. This requires a script or the x402 CLI.
Step 3: Retry with Payment Proof
curl -H "X-PAYMENT: signed_payment_data_here" \
https://api.foursec.xyz/price/ETH
Batch Script Example
#!/bin/bash
WALLET="0x_your_private_key"
SYMBOLS=("ETH" "BTC" "SOL")
for symbol in "${SYMBOLS[@]}"; do
echo "Fetching $symbol..."
x402 get "https://api.foursec.xyz/price/$symbol" --wallet "$WALLET"
sleep 1 # Rate limit friendly
done
Save to File
x402 get https://api.foursec.xyz/price/ETH --wallet 0x_key > eth_price.json
cat eth_price.json | jq '.price_usd'