API Reference

Live

Real-time DeFi intelligence data from Arbitrum. Enriched transactions, wallet analytics, and protocol insights.

Base URL https://defeyes-api.vercel.app

Authentication

Most data endpoints require an API key. Include it in your request headers:

X-API-Key: def_your_api_key_here

Get your API key →

Data Endpoints

GET /api/events API Key Query enriched DeFi events

Query enriched transaction events with filtering by protocol, action type, wallet, yield data, and more.

Query Parameters
ParameterTypeDescription
limit integer Number of results (default: 100, max: 1000)
offset integer Pagination offset
action_type string Filter by action: SUPPLY, BORROW, SWAP, FLASH_LOAN, REPAY, WITHDRAW, LIQUIDATION
protocol string Filter by protocol: "Aave V3", "CoW Protocol", "Uniswap", etc.
wallet string Filter by wallet address (origin_user)
apy_min number Minimum APY percentage (yield filter)
apy_max number Maximum APY percentage
# Find high-yield Aave supply events
curl -H "X-API-Key: def_xxx" \
  "https://defeyes-api.vercel.app/api/events?protocol=Aave%20V3&action_type=SUPPLY&apy_min=5"
Response Example
{
  "events": [
    {
      "id": 12345,
      "tx_hash": "0xabc...",
      "block_number": 417390882,
      "origin_user": "0x259B6b9C...",
      "protocol_name": "Aave V3 Pool",
      "action_type": "SUPPLY",
      "apy_percent": 5.23,
      "amount_usd": 1055.60,
      "token_symbol": "WETH",
      "timestamp": "2026-01-03T07:19:29Z"
    }
  ],
  "total": 1523,
  "limit": 100,
  "offset": 0
}
GET /api/events/export API Key Export events as CSV/JSON

Export enriched events in CSV or JSON format for analysis. Includes yield data and protocol classifications.

Query Parameters
ParameterTypeDescription
format string "csv" or "json" (default: csv)
limit integer Number of records (default: 100, max: 500)
enriched_only boolean Only return fully classified events (default: true)
# Export 100 enriched events as CSV
curl -H "X-API-Key: def_xxx" \
  "https://defeyes-api.vercel.app/api/events/export?format=csv&limit=100" \
  -o high_yield_events.csv
CSV Columns
tx_hash,block_number,timestamp,origin_user,protocol_name,action_type,
method_name,amount_usd,token_symbol,apy_percent,yield_pool,...
GET /api/wallets/{address} API Key Get wallet activity profile

Get aggregated statistics and activity profile for a specific wallet address.

Path Parameters
ParameterTypeDescription
addressrequired string Ethereum wallet address (0x...)
# Get wallet profile
curl -H "X-API-Key: def_xxx" \
  "https://defeyes-api.vercel.app/api/wallets/0x4cdba844ceb949567e3dbf94c5b0f7b3c8e5d2a1"
Response Example
{
  "address": "0x4cdba844ceb949567e3dbf94c5b0f7b3c8e5d2a1",
  "total_events": 156,
  "first_seen": "2025-11-15T10:23:45Z",
  "last_seen": "2026-01-05T08:12:33Z",
  "protocols_used": ["Aave V3", "CoW Protocol", "Uniswap"],
  "action_breakdown": {
    "SUPPLY": 45,
    "SWAP": 78,
    "BORROW": 23,
    "WITHDRAW": 10
  },
  "total_volume_usd": 125430.50
}
GET /api/stats Get platform statistics

Returns real-time statistics about enriched events, unique wallets, classification coverage, and protocol breakdown.

Response Example
{
  "enriched_events": 31239,
  "unique_wallets": 7895,
  "enrichment_progress": "99.7%",
  "protocol_breakdown": {
    "Aave V3 Pool": 17188,
    "Cow Protocol": 1305,
    "Uniswap": 856
  },
  "last_updated": "2026-01-05T08:00:00.000Z"
}

Health & Status

GET /api/health Basic health check

Simple health check endpoint to verify API is running.

{
  "status": "ok",
  "time": "2026-01-05T08:00:00.000Z"
}
GET /api/rpc-health RPC connectivity status

Check Reactive Network RPC connectivity and chain status.

{
  "status": "ok",
  "chainId": 4078,
  "blockNumber": 12345678,
  "rpcUrl": "https://mainnet-rpc.rnk.dev"
}
GET /api/storage-health Database connection status

Check database connectivity and event counts.

{
  "status": "ok",
  "database": "connected",
  "total_events": 31239,
  "last_event": "2026-01-05T08:00:00.000Z"
}

Payments & Subscriptions

POST /api/payments/create-customer Create customer & API key

Creates a new customer in the system and Stripe, generates an API key.

Request Body
ParameterTypeDescription
emailrequired string Customer email address
namerequired string Customer full name
company string Company name (optional)
Response Example
{
  "customer": {
    "id": 1,
    "email": "user@example.com",
    "stripe_customer_id": "cus_xxx"
  },
  "apiKey": "def_xxxxxxxxxxxxxxxx",
  "message": "Customer created and API key generated"
}
POST /api/payments/create-subscription Create new subscription

Create a subscription for an existing customer.

Request Body
ParameterTypeDescription
emailrequired string Customer email
planIdrequired integer Plan ID (1=Starter $19, 2=Pro $99)
paymentMethod string "stripe" or "x402"
GET /api/payments/subscriptions/{email} Get customer subscriptions

Retrieve all subscriptions for a customer by email.

Response Example
{
  "subscriptions": [
    {
      "id": 1,
      "plan_name": "Pro",
      "status": "active",
      "current_period_end": "2026-02-05T00:00:00Z"
    }
  ]
}
GET /api/usage API Key Get API usage statistics

Get your current API usage and rate limit status.

curl -H "X-API-Key: def_xxx" \
  "https://defeyes-api.vercel.app/api/usage"
Response Example
{
  "requests_today": 156,
  "requests_this_hour": 23,
  "rate_limit": 1000,
  "plan": "Pro",
  "reset_at": "2026-01-05T09:00:00Z"
}

X402 Pay-Per-Request

What is X402?

X402 enables pay-per-request API access using USDC stablecoins. Perfect for AI agents and users who prefer micropayments over subscriptions.

  • No subscription required
  • Pay only for what you use
  • Supports Base and Arbitrum networks
  • Instant settlement
GET /api/x402/pricing Get X402 pricing and payment info

Returns pricing information, supported networks, and the USDC payment wallet address.

Response

{
  "currency": "USDC",
  "wallet": "0x742d35Cc6634C0532925a3b844Bc9e7595f5bE91",
  "networks": [
    {
      "id": "base",
      "name": "Base",
      "chainId": 8453,
      "usdcContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
    },
    {
      "id": "arbitrum",
      "name": "Arbitrum One",
      "chainId": 42161,
      "usdcContract": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
    }
  ],
  "pricing": {
    "/api/stats": 0.0005,
    "/api/events": 0.001,
    "/api/events/export": 0.01,
    "/api/analytics": 0.005
  }
}
POST /api/x402/verify Verify a payment transaction

Verify that a USDC payment transaction is valid before using it for API access.

Request Body

ParameterTypeRequiredDescription
txHashstringYesTransaction hash of the USDC payment
networkstringYesNetwork: "base" or "arbitrum"
endpointstringNoEndpoint to check price for (default: /api/events)

Success Response

{
  "valid": true,
  "amount": 0.001,
  "from": "0xYourWalletAddress..."
}
FLOW X402 Payment Flow How to use X402 for API access

Step 1: Make Request

Call any data endpoint without authentication:

curl https://defeyes-api.vercel.app/api/events

Step 2: Receive 402 Response

The API returns payment instructions:

{
  "error": "Payment Required",
  "x402": {
    "price": 0.001,
    "currency": "USDC",
    "wallet": "0x742d35Cc..."
  }
}

Step 3: Send USDC Payment

Send the required USDC amount to the payment wallet on Base or Arbitrum.

Step 4: Retry with Payment Proof

Include the transaction hash in your request:

curl https://defeyes-api.vercel.app/api/events \
  -H "X-Payment-Proof: 0xYourTxHash..." \
  -H "X-Payment-Network: base"

Python Example

import requests
from web3 import Web3

# 1. Make initial request
response = requests.get("https://defeyes-api.vercel.app/api/events")

if response.status_code == 402:
    payment_info = response.json()["x402"]
    
    # 2. Send USDC (using web3.py)
    w3 = Web3(Web3.HTTPProvider("https://mainnet.base.org"))
    usdc = w3.eth.contract(address=USDC_ADDRESS, abi=ERC20_ABI)
    
    tx = usdc.functions.transfer(
        payment_info["wallet"],
        int(payment_info["price"] * 1e6)  # USDC has 6 decimals
    ).transact()
    
    tx_hash = w3.eth.wait_for_transaction_receipt(tx).transactionHash.hex()
    
    # 3. Retry with payment proof
    response = requests.get(
        "https://defeyes-api.vercel.app/api/events",
        headers={
            "X-Payment-Proof": tx_hash,
            "X-Payment-Network": "base"
        }
    )
    
    data = response.json()

Admin Endpoints

GET /api/admin/unknown-methods Get unclassified method signatures

Returns method signatures that haven't been classified yet, ordered by frequency.

Response Example
{
  "unknown_methods": [
    {
      "method_id": "0x1ad2cc3b",
      "count": 234,
      "sample_tx": "0xabc..."
    }
  ]
}
POST /api/admin/enrich Commit method classification

Add a new method classification to the enrichment registry.

Request Body
ParameterTypeDescription
method_idrequired string 4-byte method selector (0x...)
method_namerequired string Human-readable method name
action_typerequired string SUPPLY, BORROW, SWAP, FLASH_LOAN, etc.
protocol_name string Associated protocol name