Overview
The TypeScript SDK provides a convenient way to connect to Dome API’s Polymarket WebSocket server and handle real-time order data. The SDK manages connection lifecycle, automatic reconnection, and event handling.Installation
Install the SDK from npm:Basic Usage
Importing the SDK
Connecting to the WebSocket
Create a new WebSocket client instance with your API key:wss://ws.domeapi.io/YOUR_API_KEY when you create the instance.
Listening for Connection Events
Subscribing to Orders
Basic Subscription
Subscribe to receive real-time order updates for specific wallet addresses:subscribe method returns a promise that resolves with the subscription acknowledgment containing the subscription_id.
Listening for Order Events
Handle incoming order events:Complete Subscription Example
Unsubscribing
Unsubscribe from a Subscription
To stop receiving updates for a specific subscription:Unsubscribe Example
Disconnecting
Manual Disconnect
Disconnect from the WebSocket server:Disconnect Example
Reconnecting
Automatic Reconnection
The SDK can automatically reconnect when the connection is lost. Enable it when creating the client:Manual Reconnection
Manually reconnect after a disconnection:Reconnection with Subscription Restoration
Store your subscription configurations to restore them after reconnection:Complete Example
Here’s a complete example that demonstrates all features:Resources
- NPM Package: @dome-api/sdk
- GitHub Repository: dome-sdk-ts
- API Documentation: See Polymarket WebSockets for the raw WebSocket protocol