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:Basic Usage
Importing the SDK
Connecting to the WebSocket
Create a new client instance with your API key: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: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: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
- PyPI Package: dome-api-sdk
- GitHub Repository: dome-sdk-py
- API Documentation: See Polymarket WebSockets for the raw WebSocket protocol