Skip to main content

Overview

The Python 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 PyPI:
Package: dome-api-sdk

Basic Usage

Importing the SDK

Connecting to the WebSocket

Create a new client instance with your API key:
The SDK will automatically connect to wss://ws.domeapi.io/YOUR_API_KEY when you access the WebSocket methods.

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 subscription acknowledgment containing the subscription_id.

Listening for Order Events

Handle incoming order events using callbacks:

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. Configure it when initializing 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:

Getting Active Subscriptions

You can check which subscriptions are currently active:

Resources