Skip to main content

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:
Package: @dome-api/sdk

Basic Usage

Importing the SDK

Connecting to the WebSocket

Create a new WebSocket client instance with your API key:
The SDK will automatically connect to 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:
The 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:
When you disconnect, all active subscriptions are automatically cancelled.

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