Skip to Content

Data Layer

The DataRouter provides a unified dispatch surface for all data sources — HTTP APIs, x402 paid endpoints, WebSocket feeds, and MCP servers.

Fallback Chain

Configure sources in priority order. First success wins.

{ "data_sources": [ { "name": "elsa", "type": "x402", "priority": 1 }, { "name": "binance", "type": "http", "priority": 2 }, { "name": "coingecko", "type": "http", "priority": 3 }, { "name": "mcp-tools", "type": "mcp", "priority": 4 } ] }
router.fetch("spot-price", symbol="ETHUSDT") # → source: binance, cost: $0.00 router.fetch("get-token-price", token="ETH") # → source: elsa, cost: $0.002

Source Types

TypeExampleCost
x402Elsa DeFi endpoints$0.001–0.01/call
HTTPBinance, CoinGeckoFree
WebSocketLive price feedsFree
MCPAny MCP server toolFree

Token Registry

Symbols map to contract addresses per chain:

ChainTokenAddress
BaseETH (WETH)0x4200...0006
BaseUSDC0x8335...2913
EthereumETH (WETH)0xC02a...6Cc2
EthereumUSDC0xA0b8...eB48

Cost Tracking

Every source independently tracks fetches, errors, and cumulative cost:

router.cost_summary() # total_cost_usd: $0.006 # sources: # elsa: $0.006, 3 calls, 0 errors # binance: $0.000, 47 calls, 2 errors # coingecko: $0.000, 5 calls, 0 errors
Last updated on