Skip to content

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

Install CLI

npm install -g @x402/cli

Get Price

x402 get https://api.foursec.xyz/price/ETH --wallet 0x_your_key

Get Arbitrage

x402 get https://api.foursec.xyz/arbitrage-opportunity --wallet 0x_your_key

Get Volume

x402 get https://api.foursec.xyz/volume/ETH --wallet 0x_your_key

Get Historical Data

x402 get "https://api.foursec.xyz/price/history/ETH?interval=1h&limit=24" --wallet 0x_your_key

Get Volatility

x402 get https://api.foursec.xyz/volatility-index/ETH --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'

Released under the MIT License.