Why AI Agents Need a Reliable Price Oracle
Autonomous AI agents operating in crypto markets depend on accurate, low-latency price data as a foundational primitive. Whether an agent is executing a trading strategy, monitoring collateral health in a DeFi protocol, or deciding whether to sell an NFT, every financial decision starts with price.
The challenge is that crypto prices fragment across hundreds of venues — centralized exchanges, AMMs, order-book DEXes, and perpetual markets all quote different prices at any given moment. A naive agent that reads only one source will be systematically exploited by stale quotes, front-running, and wash trades.
Purple Flea's price oracle aggregates feeds from 50+ DEX and CEX sources, applies outlier filtering, and exposes clean endpoints purpose-built for agent consumption. You get the aggregated mid-price, confidence intervals, and volume-weighted averages — not raw exchange ticks that require additional processing.
Price Feed Features
Spot Price (Real-Time)
Volume-weighted average price across all active venues. Updated every 250ms. Includes bid/ask spread and 24h change.
TWAP Feeds
Time-weighted average price over configurable windows (5m, 15m, 1h, 4h, 24h). Manipulation-resistant. Chainlink-compatible response format.
OHLCV Candles
Full candlestick data at 1m, 5m, 15m, 1h, 4h, and 1d intervals. Up to 2 years of historical depth for backtesting and trend analysis.
Historical Data
Query price history with start/end timestamps. Returns JSON arrays suitable for direct ingestion into agent context windows.
Chainlink-Compatible Format
Response schema mirrors Chainlink AggregatorV3Interface. Drop-in compatible with agents already built for Chainlink oracles.
Batch Queries
Fetch up to 100 token prices in a single request. Eliminate N+1 query patterns in portfolio-evaluation agents.
Supported Assets and Markets
Purple Flea's price oracle covers a comprehensive universe of crypto assets, from the largest blue chips to long-tail ERC-20 tokens with low liquidity:
- Layer 1 assets: BTC, ETH, SOL, AVAX, BNB, MATIC, ATOM, DOT, ADA, XRP, and 200+ more
- Stablecoins: USDC, USDT, DAI, FRAX, LUSD, crvUSD — with depeg monitoring flags
- ERC-20 tokens: 10,000+ tokens indexed from Uniswap v2/v3, SushiSwap, Curve, Balancer, and other major DEXes
- Solana SPL tokens: Full coverage via Jupiter aggregator pricing
- Perpetual markets: 275 markets across Hyperliquid, GMX, dYdX, Drift, and Synthetix — including mark price and funding rate
- Liquidity pool tokens: LP token pricing for major Uniswap/Curve pools, computed from underlying reserves
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
| /price/{token} | GET | Real-time spot price for a single token (symbol or contract address) |
| /price/batch | GET | Fetch up to 100 token prices in one call. Pass tokens as comma-separated query param. |
| /price/history | GET | Historical price data. Params: token, from (unix), to (unix), interval |
| /price/twap | GET | TWAP over a specified window. Returns Chainlink-compatible price + timestamp. |
| /price/ohlcv | GET | OHLCV candlestick data. Params: token, interval (1m/5m/1h/1d), limit |
| /price/perp/{market} | GET | Perpetual market mark price, index price, and funding rate |
Code Examples
Fetch ETH Spot Price
const PURPLE_FLEA_KEY = 'pf_your_api_key_here'; async function getEthPrice() { const res = await fetch( 'https://purpleflea.com/api/price/ETH', { headers: { 'Authorization': `Bearer ${PURPLE_FLEA_KEY}` } } ); const { price, timestamp, source_count } = await res.json(); console.log(`ETH: $${price} (aggregated from ${source_count} sources)`); // ETH: $2847.23 (aggregated from 47 sources) return price; }
Batch-Fetch Portfolio Prices
async function valuatePortfolio(holdings) { // holdings = { ETH: 2.5, BTC: 0.1, USDC: 5000, ARB: 1000 } const tokens = Object.keys(holdings).join(','); const res = await fetch( `https://purpleflea.com/api/price/batch?tokens=${tokens}`, { headers: { 'Authorization': `Bearer ${PURPLE_FLEA_KEY}` } } ); const { prices } = await res.json(); let totalUsd = 0; for (const [token, amount] of Object.entries(holdings)) { totalUsd += amount * prices[token]; } return { totalUsd, prices }; }
7-Day OHLCV for Technical Analysis
async function getWeeklyOHLCV(token) { const res = await fetch( `https://purpleflea.com/api/price/ohlcv?token=${token}&interval=1h&limit=168`, { headers: { 'Authorization': `Bearer ${PURPLE_FLEA_KEY}` } } ); const { candles } = await res.json(); // candles = [{ t, o, h, l, c, v }, ...] const high7d = Math.max(...candles.map(c => c.h)); const low7d = Math.min(...candles.map(c => c.l)); console.log(`${token} 7d range: $${low7d} – $${high7d}`); return candles; }
Agent Use Cases
Portfolio Valuation
Agents periodically poll batch price endpoint to compute real-time portfolio NAV and trigger rebalancing decisions.
Take-Profit / Stop-Loss
Subscribe to price updates and automatically execute exit orders when threshold prices are crossed.
Arbitrage Detection
Compare spot prices across multiple assets in a single batch call to detect cross-asset or cross-venue arbitrage opportunities.
Risk-Adjusted Sizing
Use TWAP and volatility data to compute Kelly-criterion position sizes or VaR-based risk budgets before entry.
Collateral Monitoring
DeFi agents watch collateral-to-debt ratios using real-time prices and trigger protective actions before liquidation.
Trend Analysis
Pull OHLCV candles into agent context to compute moving averages, RSI, and Bollinger Bands for directional bias.
Rate Limits and Pricing
- 100 requests / minute
- Spot price endpoint
- Batch up to 10 tokens
- 7-day OHLCV history
- No credit card required
- 10,000 requests / minute
- All endpoints including TWAP
- Batch up to 100 tokens
- 2-year OHLCV history
- Chainlink-compatible feeds
- WebSocket streaming
- SLA 99.9% uptime
- Unlimited requests
- Dedicated infrastructure
- Custom aggregation logic
- Priority support
- On-premise deployment
Related APIs and Tools
The price oracle is one component of Purple Flea's full financial infrastructure suite for AI agents.