Integrate DerivaDEX liquidity into your DApp
- Decide whether your application needs public market depth only, user-scoped updates, or both.
- Bootstrap the current market and product baseline from the public REST family before opening live feeds.
- Subscribe to the realtime feeds that match the UI component or workflow you are building.
- Normalize incoming liquidity and pricing data into one application-owned state model.
- Reconcile that live model against periodic REST snapshots so reconnects or feed gaps do not silently drift your UI.
- Keep contract-facing actions, if any, separate from the market-data integration layer.
Choose the data path first
| If your application needs… | Start here | Do not assume… |
|---|---|---|
| current products, market metadata, or a point-in-time market snapshot | REST API | REST by itself will keep a live order book synchronized |
| continuously updated book depth or mark price | Realtime API | the WebSocket feed replaces initial REST bootstrap |
| user-scoped order, strategy, or trader updates | Realtime Connection Model plus the relevant filtered user-data feeds | public market-data subscriptions alone are enough for account reconciliation |
| settlement or governance transaction flows | Smart Contract Addresses and Core Contract Reference | the smart-contract layer is the primary source of live order-book liquidity |
Build the initial market view
- Use REST to fetch the products and symbols your DApp intends to display.
- Load the latest public market snapshot your screen or service needs before opening the WebSocket.
- Record the symbol set, any aggregation choices, and the environment you are targeting so later reconnect logic re-subscribes to the same shape.
Layer realtime updates on top
- Subscribe to
ORDER_BOOK_L2,ORDER_BOOK_L3, orMARK_PRICEaccording to the depth and latency requirements of the DApp view. - If the application also tracks user state, subscribe separately to the filtered
ORDER_UPDATE,STRATEGY_UPDATE, andTRADER_UPDATEfeeds rather than mixing market and account assumptions together. - Apply messages in top-level
ordinalorder for the active connection. - Keep
globalOrdinalper update family so you can reconcile one family after reconnect without cross-comparing unrelated feed types.
Keep the app-state model honest
- treat REST as the initial baseline
- treat realtime as the live-update layer
- persist the subscription shape and the last processed ordinals
- run periodic REST reconciliation for the views that must stay exact