API Reference
DBot OfficialDBot DashboardPricing

Fast Buy / Sell Task (WS)

Used to query the order status of Fast Buy / Sell. The orderId comes from the Fast Buy / Sell response.

FreePlusProEnterprise积分消耗
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

{
  "id": 1761291309, // Call ID; the response returns the same ID as the request
  "method": "getSwapOrder", // Method to query Fast Buy / Sell task
  "params": {
    "orderId": "mh4arjjr00109a" // Fast buy/sell task id
  }
}

Response Data

{
  "method": "rpcResponse", // RPC response
  "id": 1761291309, // Call ID
  "result": {
    "err": false, // Request result status; false means succeeded, true means failed
    "res": {
      "id": "mh4arjjr00109a", // Fast buy/sell task id
      "chain": "solana", // Chain (solana/ethereum/base/bsc/tron)
      "tradeType": "buy", // Trade type, values buy or sell
      "state": "done", // Order status: init (initial), processing, done (completed), fail, expired
      "txPriceUsd": 0.000020976535179060357, // Actual transaction price (USD)
      "swapHash": "5cL65PoEA5bn1fqkwjGqEPMJsZKcTyze36pUNVU3HvXkMtm1gBzzoW4RQnMMpc9iuAEBohcjNVKufQR2U9nVFDpf", // Transaction hash
      "swapLink": "https://solscan.io/tx/5cL65PoEA5bn1fqkwjGqEPMJsZKcTyze36pUNVU3HvXkMtm1gBzzoW4RQnMMpc9iuAEBohcjNVKufQR2U9nVFDpf", // Transaction link
      "errorCode": "", // Error type
      "errorMessage": "", // Error message
    }
  }
}

Example in NodeJS

const WebSocket = require('ws')

function main() {
  const ws = new WebSocket('wss://api-data-v1.dbotx.com/trade/ws/', {
    headers: {
      'x-api-key': 'YOUR_API_KEY',
    },
  })

  ws.on('open', () => {
    ws.send(
      JSON.stringify({
         "id": 1761291309,
         "method": "getSwapOrder",
         "params": {
             "orderId": "mh4arjjr00109a"
          }
      })
    )

    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-data-v1.dbotx.com/trade/ws/"
    headers = {"x-api-key": "YOUR_API_KEY"}
    msg = {
       "id": 1761291309,
       "method": "getSwapOrder",
       "params": {
           "orderId": "mh4arjjr00109a"
    }
 }

    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_for_messages():
            async for message in ws:
                print(message)

        await asyncio.gather(keep_alive(), listen_for_messages())

if __name__ == "__main__":
    asyncio.run(main())

Response data visualization reference