Skip to content

speteai/agentdata-api

Repository files navigation

AgentData API — x402 Crypto Market Data for AI Agents

Real-time crypto market data API designed for AI agents. Pay-per-request with USDC on Base Mainnet via the x402 protocol. 16 endpoints. No accounts. No API keys. No subscriptions.

Live Base Mainnet x402 v2 License: MIT

🌐 Live: agentdata-api.com · 📊 Dashboard: agentdata-api.com/admin · 🤖 MCP: https://agentdata-api.com/mcp


Why AgentData API?

AI agents can't sign up for traditional APIs. They can't enter a credit card, fill out a form, or wait for an API key to be emailed. But they can sign USDC transactions.

AgentData API exposes 16 crypto market data endpoints behind the x402 payment protocol. An agent sends a GET request, receives HTTP 402 Payment Required, signs an ERC-3009 TransferWithAuthorization message, and resends. The server settles the payment on-chain and returns the data. Cost: $0.001–$0.005 per request.

No accounts. No API keys. No rate limits you have to negotiate. Pay only for what you use.

Features

  • 16 production endpoints across Market Data, On-Chain, Arbitrage, Technical Analysis, Sentiment, and Historical data
  • Self-hosted facilitator — no Coinbase Developer Platform lock-in, no third-party outage risk
  • Base Mainnet native — USDC settlement via x402 v2 with exact scheme
  • Agent-discoverable — OpenAPI 3.0, Google A2A Agent Card, llms.txt, Bazaar extension, MCP remote transport
  • Redis caching — 15s–300s TTLs protect against upstream rate limits
  • On-chain revenue tracking — live dashboard with USDC inflow monitoring and lazy transaction verification
  • SQLite analytics — request logging, error tracking, upstream failure monitoring
  • Production hardened — systemd auto-restart, cron uptime monitoring, balance alerting, auto-refill scripts

Endpoints

Market Data

Endpoint Price Description
GET /api/prices $0.001 Real-time prices for BTC, ETH, SOL, BNB, XRP
GET /api/funding-rates $0.001 Perpetual futures funding rates with long/short bias
GET /api/market-overview $0.002 Full market overview with sentiment and arbitrage signals
GET /api/volatility $0.001 24h volatility, range, annualized vol for BTC/ETH/SOL
GET /api/liquidation-levels $0.002 Estimated liquidation zones by leverage (5x/10x/20x)
GET /api/correlation $0.001 30-day price correlation matrix (ETH/BTC, SOL/BTC, SOL/ETH)

On-Chain Data

Endpoint Price Description
GET /api/gas-prices $0.001 Multi-chain gas prices (Base, Ethereum, Solana)
GET /api/base-activity $0.002 Base Mainnet activity: TPS, blocks, gas utilization
GET /api/defi-yields $0.002 Top DeFi yields (Aave, Compound, Morpho, Pendle) via DefiLlama

Arbitrage & Cross-Venue

Endpoint Price Description
GET /api/arbitrage-opportunities $0.003 Cross-exchange spread opportunities (MEXC/Binance/Bybit/OKX)
GET /api/dex-vs-cex $0.003 DEX aggregated prices vs CEX with spread analysis

Technical Analysis

Endpoint Price Description
GET /api/indicators $0.002 RSI, MACD, Bollinger Bands, ATR. ?symbol=BTCUSDT&interval=1h
GET /api/support-resistance $0.003 Support & resistance levels via fractal analysis

Sentiment & Historical

Endpoint Price Description
GET /api/sentiment $0.001 Composite sentiment: Fear & Greed + funding-based
GET /api/stablecoin-health $0.001 USDC/DAI live depeg check + top 10 stablecoins
GET /api/historical $0.005 OHLCV candles for backtesting. ?symbol=BTCUSDT&interval=1d&limit=500

Quick Start for Agents

Option 1: Claude Desktop (MCP)

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "agentdata": {
      "url": "https://agentdata-api.com/mcp"
    }
  }
}

Restart Claude Desktop. The 16 tools become available in any conversation.

Option 2: Direct HTTP (any language)

# Step 1: Request the endpoint — receive 402
curl -i https://agentdata-api.com/api/prices

# Step 2: Decode the PAYMENT-REQUIRED header (base64 JSON)
# {"x402Version":2,"accepts":[{"scheme":"exact","network":"eip155:8453","maxAmountRequired":"1000","asset":"0x833...","payTo":"0x844...",...}]}

# Step 3: Sign ERC-3009 TransferWithAuthorization message with your wallet
# Step 4: Resend with PAYMENT-SIGNATURE header
curl -H "PAYMENT-SIGNATURE: eyJ4NDA..." https://agentdata-api.com/api/prices

See scripts/payment-test.js for a complete working Node.js client using viem.

Option 3: ElizaOS Plugin

import { agentdataPlugin } from '@agentdata/plugin-elizaos';

export const character = {
  plugins: [agentdataPlugin],
  settings: {
    AGENTDATA_BUYER_PRIVATE_KEY: '0x...', // wallet funded with USDC on Base
  },
};

Architecture

┌─────────────┐     402      ┌─────────────────┐
│  AI Agent   │◄─────────────┤  Nginx (HTTPS)  │
│  (Claude/   │              │  Rate limiting  │
│   ElizaOS)  │     signed   │  /mcp /api/...  │
│             │──payment────►│                 │
└─────────────┘              └────────┬────────┘
                                      │
                             ┌────────▼─────────┐
                             │  Express Server  │
                             │  ┌────────────┐  │
                             │  │ x402/v2    │  │
                             │  │ middleware │  │
                             │  └─────┬──────┘  │
                             │        │          │
                             │  ┌─────▼──────┐  │
                             │  │ Local      │  │
                             │  │ Facilitator│  │──► Base RPC
                             │  │ (viem)     │  │    (eth_call,
                             │  └─────┬──────┘  │     eth_sendRaw)
                             │        │          │
                             │  ┌─────▼──────┐  │
                             │  │ Redis      │  │
                             │  │ cache      │──┼──► Upstream APIs
                             │  │ (DB 5)     │  │    (MEXC, Binance,
                             │  └────────────┘  │     DefiLlama, etc.)
                             │                  │
                             │  ┌────────────┐  │
                             │  │ SQLite     │  │
                             │  │ analytics  │  │
                             │  │ + revenue  │  │
                             │  └────────────┘  │
                             └──────────────────┘

Tech Stack

  • Node.js 20 + Express 5
  • viem for EVM wallet and EIP-712 typed data signing
  • @x402/core v2.9 with local facilitator
  • @modelcontextprotocol/sdk for MCP remote transport
  • Redis (ioredis) with isolated DB for upstream caching
  • better-sqlite3 for analytics and payment indexing
  • systemd for service management
  • nginx for HTTPS, rate limiting, MCP proxy
  • Let's Encrypt for SSL

Discovery & Registries

The service is listed/compatible with:

Self-Hosting

Requirements

  • Ubuntu 22.04+ (or any Linux with systemd)
  • Node.js 20+
  • Redis 6+ (for caching layer)
  • nginx (reverse proxy + SSL termination)
  • Domain with DNS A-record to your server
  • Base Mainnet wallet with ~0.001 ETH for facilitator gas

Install

git clone https://github.com/speteai/agentdata-api.git
cd agentdata-api
npm install
cp .env.example .env
# Edit .env with your wallet addresses and RPC URL
npm start

Environment Variables

Variable Required Description
WALLET_ADDRESS Payee wallet (receives USDC)
FACILITATOR_PRIVATE_KEY Signer for settlement transactions (needs ETH for gas)
BASE_RPC_URL recommended Base Mainnet RPC (default: https://mainnet.base.org)
PORT - Server port (default: 4021)
NODE_ENV - production = Base Mainnet, else Base Sepolia

Production Deployment

  • systemd unit (systemd/x402-agentdata.service) — auto-restart, sandboxing
  • nginx config (nginx/agentdata-api.conf) — HTTPS, rate limiting, MCP endpoint
  • cron scripts (scripts/) — uptime monitoring, balance alerting, auto-refill

Monetizing Your Own Data

If you have a data source (on-chain analytics, ML predictions, proprietary signals), you can turn it into a paid API in hours:

  1. Fork this repo
  2. Replace the fetch*() functions with your data source
  3. Configure your wallet addresses
  4. Deploy with the provided systemd + nginx templates

The facilitator handles all x402 payment complexity. You only write the data fetcher.

SEO Keywords

x402 API, AI agent API, crypto market data API, pay-per-request API, USDC API, Base Mainnet API, agentic payments, machine-to-machine payments, ERC-3009, EIP-3009, HTTP 402, Model Context Protocol MCP server, ElizaOS plugin, Coinbase x402, Linux Foundation x402, agent economy, DeFAI, crypto data for AI agents, autonomous agent payments

License

MIT — see LICENSE.

Links

Related repositories:


Built for the Agent Economy · Powered by x402 · Settled on Base

Releases

No releases published

Packages

 
 
 

Contributors