API Reference
DBot OfficialDBot DashboardPricing

Subscribe Trade Results (WS)

Used to subscribe to all or specific types (e.g., fast buy / sell, limit orders, etc.) of trade results (available for Plus / Pro / Enterprise)

FreePlusProEnterpriseCredit Usage
0

URL

wss://api-bot-v1.dbotx.com/trade/ws/

Notes

To ensure the availability and stability of the WebSocket connection, a heartbeat subscription must be sent at least once every minute (recommended every 30–55 seconds), otherwise the system will automatically disconnect the timeout link

Request Example

{
  "method": "subscribeTradeResults", // Currently fixed as "subscribeTradeResults"
  "tradeTypeFilter": [ // Trade types to subscribe: An empty array [] subscribes to all trade types, including any added in the future
    "swap_buy_success", // Subscribe to to successful fast buy notification
    "swap_buy_fail", // Subscribe to failed fast buy notification
    "swap_sell_success", // Subscribe to successful fast sell notification
    "swap_sell_fail", // Subscribe to failed fast sell notification
    "limit_buy_success", // Subscribe to successful limit buy notification
    "limit_buy_fail", // Subscribe to failed limit buy notification
    "limit_sell_success", // Subscribe to successful limit sell notification
    "limit_sell_fail", // Subscribe to failed limit sell notification
    "swap_take_profit_success", // Subscribe to successful take-profit sell from fast buy/sell notification
    "swap_take_profit_fail", // Subscribe to failed take-profit sell from fast buy/sell notification
    "swap_stop_loss_success", // Subscribe to a successful stop-loss sell from fast buy/sell notification
    "swap_stop_loss_fail", // Subscribe to failed stop-loss sell from fast buy/sell notification
    "swap_trailing_stop_success", // Subscribe tosuccessful trailing stop sell from fast buy/sell notification
    "swap_trailing_stop_fail", // Subscribe to failed trailing stop sell from fast buy/sell notification
    "follow_take_profit_success", // Subscribe to successful take-profit sell from copy trading notification
    "follow_take_profit_fail", // Subscribe to failed take-profit sell from copy trading notification
    "follow_stop_loss_success", // Subscribe to successful stop-loss sell from copy trading notification
    "follow_stop_loss_fail", // Subscribe to failed stop-loss sell from copy trading notification
    "follow_trailing_stop_success", // Subscribe to successful trailing stop sell from copy trading notification
    "follow_trailing_stop_fail", // Subscribe to failed trailing stop sell from copy trading notification
    "follow_buy_success", // Subscribe to successful copy buy notification
    "follow_buy_fail", // Subscribe to failed copy buy notification
    "follow_sell_success", // Subscribe to successful copy sell notification
    "follow_sell_fail", // Subscribe to failed copy sell notification
  ]
}

Response Data

{
  "method": "subscribeResponse", // Currently fixed as "subscribeTradeResults"
  "result": {
    "message": "Connected and subscribed"
  }
}

Example in NodeJS

const WebSocket = require('ws')
function main() {
  const ws = new WebSocket('wss://api-bot-v1.dbotx.com/trade/ws/', {
    headers: {
      'x-api-key': 'YOUR_API_KEY',
    },
  })
  ws.on('open', () => {
    ws.send(
      JSON.stringify({
        method: 'subscribeTradeResults',
        tradeTypeFilter: [
                  'swap_buy_success',
                  'swap_buy_fail',
                  'swap_sell_success',
                  'swap_sell_fail',
          ],
        },
      })
    )
    setInterval(() => {
      ws.ping()
    }, 30000)
  })
  ws.on('message', res => {
    console.log('res:', res.toString('utf-8'))
  })
}
main()

Example in Python

import asyncio
import websockets
import json
async def main():
    uri = "wss://api-bot-v1.dbotx.com/trade/ws/"
    headers = {"x-api-key": "YOUR_API_KEY"}
    msg = {
        "method": "subscribeTradeResults",
        "tradeTypeFilter": ["swap_buy_success", "swap_buy_fail", "swap_sell_success", "swap_sell_fail"]
    }
    async with websockets.connect(uri, additional_headers=headers) as ws:
        await ws.send(json.dumps(msg))
        async def keep_alive():
            while True:
                await ws.ping()
                await asyncio.sleep(30)

        async def listen():
            async for message in ws:
                print("res:", message)
        await asyncio.gather(keep_alive(), listen())
if __name__ == "__main__":
    asyncio.run(main())