Real-time transaction graph analysis, address clustering, protocol revenue tracking, and token flow visualization โ built for autonomous AI agents operating across 5 blockchains.
From raw transaction data to actionable signals โ Purple Flea on-chain analytics extracts meaning from blockchain noise so your agent can act with confidence.
Trace fund flows across wallets, identify transaction clusters, and map entity relationships. Detect wash trading, mixer usage, and cross-chain bridges in milliseconds.
Group addresses belonging to the same entity using heuristic and ML-based clustering. 50M+ labeled addresses including CEXs, protocols, whales, and known bad actors.
Monitor real-time fee revenue, TVL, and usage metrics across 500+ DeFi protocols. Compare protocol health over time with historical breakdowns by day/week/month.
See exactly where tokens are moving โ from whales to protocols, DEX to CEX, chain to chain. Identify accumulation and distribution phases before price moves.
Real-time risk assessment on any address: sanctions exposure, hack involvement, mixer interaction, and abnormal transaction patterns. Score from 0โ100 in under 100ms.
Track volume, liquidity depth, and trading pairs across Uniswap, Curve, Raydium, and 200+ other DEXs. Identify volume spikes before they show up in price.
Unified analytics API across all major blockchains. Query once, get data from everywhere.
RESTful API with consistent response shapes. All endpoints return JSON and support chain parameter for multi-chain queries.
Each address gets a composite risk score built from multiple signal categories. Your agent can gate transactions based on counterparty risk.
Your trading agent reads on-chain data to build proprietary signals before price moves. Whale accumulation, exchange inflows, protocol revenue growth โ all become tradeable edges.
Escrow agents and payment agents must verify counterparty risk before releasing funds. Our risk API integrates directly into payment flows for real-time AML screening.
A complete example showing how an AI trading agent uses on-chain analytics to generate and execute trade decisions on Purple Flea.
import requests
import time
from dataclasses import dataclass
from typing import Optional
# Purple Flea API configuration
BASE_URL = "https://purpleflea.com"
API_KEY = "pf_live_your_key_here"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
@dataclass
class OnChainSignal:
token: str
whale_accumulation_usd: float
exchange_inflow_usd: float
dex_volume_ratio: float # current / 30d avg
risk_score: int
composite_score: float # -1.0 (bearish) to +1.0 (bullish)
def fetch_on_chain_signal(token: str, chain: str = "ethereum") -> OnChainSignal:
"""Fetch composite on-chain signal for a token."""
# Get token flow data
flows = requests.get(
f"{BASE_URL}/analytics/token-flows",
params={"token": token, "chain": chain, "window": "24h"},
headers=HEADERS
).json()
# Get DEX volume (compare to 30d average)
dex = requests.get(
f"{BASE_URL}/analytics/dex-volume",
params={"pair": f"{token}/USDC", "chain": chain, "anomaly": "true"},
headers=HEADERS
).json()
whale_net = flows.get("whale_net_usd", 0)
exch_inflow = flows.get("exchange_inflow_usd", 0)
vol_ratio = dex.get("volume_vs_30d_avg", 1.0)
# Build composite signal:
# +whale_acc, -exchange_inflow, +dex_spike
composite = 0.0
if whale_net > 5_000_000:
composite += 0.35
if exch_inflow < 2_000_000:
composite += 0.25
if vol_ratio > 2.5:
composite += 0.20
if exch_inflow > 15_000_000:
composite -= 0.40
return OnChainSignal(
token=token,
whale_accumulation_usd=whale_net,
exchange_inflow_usd=exch_inflow,
dex_volume_ratio=vol_ratio,
risk_score=0,
composite_score=max(-1.0, min(1.0, composite))
)
def execute_trade_if_signal_strong(signal: OnChainSignal, threshold: float = 0.5):
"""Open a perp position if signal is strong enough."""
if signal.composite_score >= threshold:
side = "long"
notional = 1000 # USDC
elif signal.composite_score <= -threshold:
side = "short"
notional = 1000
else:
print(f"Signal too weak ({signal.composite_score:.2f}), holding.")
return None
# Submit via Purple Flea Trading API
order = requests.post(
f"{BASE_URL}/trading/perps/open",
json={
"symbol": f"{signal.token}-PERP",
"side": side,
"notional_usdc": notional,
"leverage": 3,
"signal_source": "on-chain-analytics"
},
headers=HEADERS
).json()
print(f"Opened {side} {signal.token} | "
f"Score: {signal.composite_score:.2f} | "
f"Order ID: {order.get('order_id')}")
return order
# Main agent loop
WATCHLIST = ["ETH", "SOL", "BTC", "MATIC"]
if __name__ == "__main__":
while True:
for token in WATCHLIST:
signal = fetch_on_chain_signal(token)
print(f"{token}: composite={signal.composite_score:.2f}, "
f"whale={signal.whale_accumulation_usd/1e6:.1f}M, "
f"vol_ratio={signal.dex_volume_ratio:.1f}x")
execute_trade_if_signal_strong(signal)
time.sleep(3600) # Re-evaluate every hour
Get your API key, connect to the on-chain analytics endpoints, and give your agent the data edge it needs.