@mobula/sdk, with practical patterns taken from the open-source MTT (Mobula Trader Terminal) codebase.
Prerequisites
- Node.js 18+ or Bun
- A Mobula API key (Growth or Enterprise plan) — get one at admin.mobula.io
@mobula/sdkinstalled in your project
Quick Start
Connect to Pulse V2 and start receiving real-time token data in under 10 lines:How the SDK StreamClient Works
TheMobulaClient exposes a streams property — an instance of StreamClient that manages WebSocket connections. Key behaviors:
Core Methods
Understanding the Payload
The subscription payload controls what data you receive. Here’s the full shape:View Models
Message Types
The stream sends three message types:init — Initial Data Snapshot
Sent immediately after subscribing. Contains the current state for all views:
update-token — Token Data Changed
Sent when a token’s metrics update (price, holders, market cap, etc.):
new-token — New Token Appeared
Sent when a token enters a view for the first time:
REST + WebSocket Pattern
MTT uses a REST-first, WebSocket-second pattern for the best user experience: load data instantly via REST, then switch to WebSocket for live updates. Here’s a simplified version of how MTT does it (apps/mtt/src/features/pulse/hooks/usePulseV2.ts):
The REST and WebSocket APIs accept the same payload shape, so you can reuse your view configuration for both.
How MTT Implements Pulse WSS
MTT is Mobula’s open-source trading terminal. Its Pulse implementation is a production reference you can study and adapt. Here are the key architectural pieces:Architecture
Key Files in the MTT Codebase
SDK Client Wrapper
MTT wraps the SDK to support both server-side (SSR) and client-side modes. Here’s the stream subscription pattern fromsdkClient.ts:
Update Batching for 60fps
MTT batches incoming WebSocket messages usingrequestAnimationFrame to avoid render storms:
Pause and Resume
The SDK supports pausing specific views without disconnecting:Filtering
Pass filters inside each view to narrow down the token stream. Filters use{ gte, lte } range syntax:
Available Filter Fields
Multi-Chain Support
Subscribe to multiple chains in a single view:Custom WSS URLs
The SDK lets you override WebSocket endpoints per stream type:Unsubscribing and Cleanup
Always clean up subscriptions when your component unmounts or when you no longer need the data:Full React Example
Here’s a minimal but complete React hook for Pulse V2, inspired by MTT’s implementation:Next Steps
Pulse V2 API Reference
Full API reference with all parameters and response schemas
Filter Details
Complete filter reference with operators and examples
Build Full Pulse UI
Step-by-step guide to building a complete Pulse UI with Next.js
MTT Source Code
Explore the full open-source trading terminal