Real-Time Data Streaming

Smart Money API supports real-time data streaming via WebSocket and Server-Sent Events (SSE). Stream live whale movements, exchange flows, miner metrics, and market signals without polling. This guide covers WebSocket connection setup, channel subscriptions, and handling real-time events with millisecond latency.

WebSocket Connection Setup

WebSocket connections enable bidirectional real-time communication. Connect to wss://api.smartmoneyapi.com/ws and authenticate immediately after connection.

WebSocket benefits: Lower latency (50-100ms vs 1000ms polling), bi-directional (server can push anytime), efficient bandwidth usage, and no connection overhead per message. Perfect for trading bots requiring immediate market signals.

Server-Sent Events (SSE)

SSE provides unidirectional server-to-client streaming over HTTP. Simpler than WebSocket for read-only use cases. Connect to https://api.smartmoneyapi.com/sse and the server pushes updates automatically. Best for dashboards and monitoring applications that don't require two-way communication.

Available Channels

Smart Money API provides 20+ streaming channels covering all market intelligence:

Channel Subscriptions

Subscribe to specific channels by sending subscription messages. Each subscription can have filters for precision targeting.

JAVASCRIPT
const ws = new WebSocket('wss://api.smartmoneyapi.com/ws'); ws.onopen = () => { // Authenticate ws.send(JSON.stringify({ action: 'auth', api_key: 'your_api_key' })); // Subscribe to whale movements >500 BTC ws.send(JSON.stringify({ action: 'subscribe', channel: 'whale.movements', filters: { min_btc: 500, whale_tier: 'MEGA' } })); // Subscribe to exchange flows ws.send(JSON.stringify({ action: 'subscribe', channel: 'exchange.flows' })); }; ws.onmessage = (event) => { const data = JSON.parse(event.data); if (data.type === 'whale_movement') { console.log(`ALERT: ${data.amount_btc} BTC whale movement to ${data.direction}`); } else if (data.type === 'exchange_inflow_spike') { console.log(`Exchange inflow spike: ${data.inflow_btc} BTC detected`); } };

Message Format

All real-time messages follow consistent JSON format with timestamp, event type, and data payload. Event IDs enable deduplication in case of retransmission.

Reconnection Handling

Implement exponential backoff reconnection: 1s, 2s, 4s, 8s, 30s intervals. Store subscription list to automatically re-subscribe after reconnection. Smart Money API supports persistent connection state for seamless failover.

Performance Optimization

Use channel filters to reduce message volume. Subscribe to specific whale tiers, minimum transaction amounts, and metric thresholds. Process messages asynchronously using queues to prevent blocking. Implement backpressure handling if processing falls behind message rate.

PYTHON
import asyncio import websockets import json from collections import deque class RealtimeMonitor: def __init__(self, api_key): self.api_key = api_key self.message_queue = asyncio.Queue(maxsize=1000) self.subscriptions = [] async def connect(self): uri = 'wss://api.smartmoneyapi.com/ws' async with websockets.connect(uri) as ws: await ws.send(json.dumps({ 'action': 'auth', 'api_key': self.api_key })) # Subscribe to channels await ws.send(json.dumps({ 'action': 'subscribe', 'channel': 'whale.movements', 'filters': {'min_btc': 100} })) # Receive messages async for message in ws: data = json.loads(message) await self.message_queue.put(data) async def process_messages(self): while True: msg = await self.message_queue.get() await self.handle_message(msg) self.message_queue.task_done() async def handle_message(self, msg): if msg['type'] == 'whale_movement': print(f"Whale: {msg['amount_btc']} BTC") asyncio.run(RealtimeMonitor('key').connect())

Complete Examples

See integration guides for full working examples in Python, JavaScript, Go, and Rust. Reference implementations handle reconnection, message processing, error handling, and production monitoring patterns.

Start free — 200 calls/day, no card

Get live whale flow, funding, open interest and on-chain data across 3 exchanges from one API. Free tier, no credit card, upgrade any time.

Start free →
Try the live API console → (no account needed)
Get your API key in 30 seconds

Wire this integration to live data in minutes. Free API key, 200 calls/day, no card required.

Get your API key →