Introduction

The List Open Orders WebSocket API provides real-time updates for all Open Orders matching the specified criteria. This API is useful for monitoring open orders for specific currency pairs.

WebSocket Endpoint

wss://api.doppapp.com/v1/private/ws/get_open_orders_by_currency?wallet_address={wallet_address}&currency={currency}

This endpoint provides updates for all Open Orders matching the specified criteria.

Query Parameters

The WebSocket connection accepts the following optional query parameter:

  • wallet_address: Filter updates by wallet Address ID.
  • currency: Filter updates by base currency.

Message Format

The server sends messages in JSON format. Each message represents an Open Orders update and has the following structure:

[
  {
    "open_orders": [
      {
        "wallet_address": "string",
        "amount": 0,
        "amount_filled": 0,
        "base_currency": "string",
        "creation_timestamp": 0,
        "direction": "string",
        "instrument_id": "string",
        "instrument_name": "string",
        "order_id": 0,
        "order_state": "string",
        "price": 0
      }
    ]
  }
]

Examples

Python

Here’s an example of how to connect to the WebSocket and receive updates using Python:

import websockets
import asyncio
import json

async def main():
    
    currency = "BTC"
    wallet_address = "12345"
    uri = f"wss://api.doppapp.com/v1/public/ws/get_open_orders_by_currency?wallet_address={wallet_address}&currency={currency}

    async with websockets.connect(uri) as websocket:
        print("Connected to WebSocket")

        while True:
            try:
                message = await websocket.recv()
                data = json.loads(message)
                print(f"Received update: {data}")
            except websockets.exceptions.ConnectionClosed:
                print("WebSocket connection closed")
                break

asyncio.get_event_loop().run_until_complete(main())

To run this example:

  1. Install the required library: pip install websockets
  2. Save the code to a file (e.g., main.py)
  3. Run the script: python main.py

Error Handling

The WebSocket may close the connection with specific codes in case of errors:

  • 1000: Normal closure
  • 1008: Policy violation (e.g., invalid filter)
  • 1011: Internal server error

Clients should be prepared to handle these closure codes and implement appropriate reconnection logic.

Rate Limiting

To prevent abuse, the API implements rate limiting. Clients that exceed the allowed number of connection attempts may be temporarily blocked. Implement exponential backoff in your client applications to handle rate limiting gracefully.