Mobula provides real-time WebSocket streams for accessing live blockchain data with minimal latency. Whether you need market updates, trade feeds, or position tracking, our streaming API delivers data as it happens.
TypeScript SDK (Recommended)
The easiest way to consume WebSocket streams is through our official SDK, which handles connection management, reconnection, and provides full type safety:
npm install @mobula_labs/sdk
import { MobulaClient } from '@mobula_labs/sdk';
const client = new MobulaClient({
apiKey: 'your-api-key', // Get one at https://admin.mobula.io
});
// Subscribe to market data
client.streams.subscribe('market', { asset: 'bitcoin' }, (data) => {
console.log('Market update:', data);
});
// Subscribe to trades
client.streams.subscribe('trade', {
asset: 'bitcoin',
blockchain: 'ethereum',
pair: 'WETH/USDC',
}, (data) => {
console.log('Trade:', data);
});
// Subscribe to OHLCV candles
client.streams.subscribe('ohlcv', {
asset: 'bitcoin',
interval: '1h',
}, (data) => {
console.log('OHLCV update:', data);
});
// Subscribe to Pulse V2
client.streams.subscribe('pulse-v2', {
model: 'default',
chainId: ['solana:solana'],
}, (data) => {
console.log('Pulse update:', data);
});
Available Stream Types
| Stream Type | Description |
|---|
market | Market data updates |
market-details | Detailed market information |
token-details | Token information updates |
trade / fast-trade | Trade updates |
ohlcv | OHLCV candle updates |
holders | Token holder updates |
pulse-v2 | Pulse V2 data stream |
position | Position updates |
funding | Funding rate updates |
stream-evm | EVM blockchain stream |
stream-svm | Solana blockchain stream |
SDK Features
- Automatic reconnection: Connection drops are handled automatically
- Heartbeat management: Keep connections alive without manual intervention
- Connection pooling: Efficient management of multiple subscriptions
- Full type safety: TypeScript types for all stream payloads
- Easy unsubscription: Clean up resources with returned unsubscribe functions
// Unsubscribe when done
const unsubscribe = client.streams.subscribe('market', { asset: 'bitcoin' }, callback);
// Later...
unsubscribe();
Direct WebSocket Connection
If you prefer to connect directly without the SDK, you can use the WebSocket endpoint:
URL: wss://api.mobula.io
Example subscription message:
{
"type": "market-details",
"authorization": "YOUR-API-KEY",
"payload": {
"pools": [
{
"blockchain": "evm:1",
"address": "0x1234567890abcdef1234567890abcdef12345678"
}
]
}
}
The SDK handles authentication, message formatting, and connection management automatically. We recommend using it for production applications.
Stream Categories