API Reference
DBot OfficialDBot DashboardPricing

Subscribe Wallet Live Trades (WS)

Used to subscribe to all real-time transaction data of a specified wallet

FreePlusProEnterprise积分消耗
0

URL

wss://api-data-v1.dbotx.com/data/ws/

说明

为保证WebSocket连接的可用性和稳定性,需要至少每1分钟(建议每30-55秒)进行一次心跳订阅,否则系统会自动断开超时链接

请求示例

{
  "method": "subscribe", // Action performed: "subscribe" for subscription, "unsubscribe" for unsubscription
  "type": "walletTx", // Subscription type: "tx" for real-time transactions, "pairsInfo" for multi-pair data updates, "newPairInfo" for newly created pools / pairs, "pairInfo" for single pair data update, "migratedPairInfo" for latest migrated trading pairs, "walletTx" for wallet live trades
  "args": {
    "walletAddress": "4N389xaQ2jRWDxpXmzwUCEnCQHDcDfprCsTqEd2taPoU", // Subscribed wallet address
  }
}

响应数据

{
  "status": "ack", // Subscription status, "ack" for success
  "method": "subscribeResponse",
  "result": {
    "type": "walletTx", // Subscription type: "tx" for real-time transactions, "pairsInfo" for multi-pair data updates, "newPairInfo" for newly created pools / pairs, "pairInfo" for single pair data update, "migratedPairInfo" for latest migrated trading pairs, "walletTx" for wallet live trades
    "t": 1751008703051,
    "subscribed": [
      "walletTx"
    ],
    "message": "Connected and subscribed"
  }
}

以NodeJS为例

const WebSocket = require('ws')
function main() {
  const ws = new WebSocket('wss://api-data-v1.dbotx.com/data/ws/', {
    headers: {
      'x-api-key': 'YOUR_API_KEY',
    },
  })
  ws.on('open', () => {
    ws.send(
      JSON.stringify({
        method: 'subscribe',
        type: 'walletTx',
        args: {
            "walletAddress":'CzhUkaHFjo8s9sp2SuM6QMrV518pRsu3KmqKRhNvMLeN'
        },
      })
    )
    setInterval(() => {
      ws.ping()
    }, 30000)
  })
  ws.on('message', res => {
    console.log('res:', res.toString('utf-8'))
  })
}
main()

以Python为例

import asyncio
import websockets
import json

async def main():
    uri = "wss://api-data-v1.dbotx.com/data/ws/"
    headers = {"x-api-key": "YOUR_API_KEY"}
    msg = {
        "method": "subscribe",
        "type": "walletTx",
        "args": {
            "walletAddress":'CzhUkaHFjo8s9sp2SuM6QMrV518pRsu3KmqKRhNvMLeN'
            ]
        }
    }

    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())