Subscribe Live Trades (WS)

Subscribe Live Trades: Credit Usage 0

Used to subscribe to all live trades of a specified pair, including buy, sell, add liquidity, and remove liquidity

URL

Header: X-API-KEY

(Please do not disclose your API Key to anyone. If you are at risk of losing it, please refresh it.)

Notes

  1. X-API-KEY can be obtained in your "Dashboard", go to check: Dashboard

  2. 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

  3. Example in 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: 'tx',
        args: {
          pair: [
            'CzhUkaHFjo8s9sp2SuM6QMrV518pRsu3KmqKRhNvMLeN',
            '7P1f3rzUV9493vEoA7nbrEJoV9NnWfUaGePgjGUb6EX9',
            '7F1AHnpwqB6khEMj9iVNdWXB5MTrLjYrQy8msj57rpZ7',
            '343R8XMAqqGAkLpECaxwjH1Zi7a83mindmmpQS5uCvrF',
            '12oPgdnCCNxanJsXCo68p1XjNLqvaA9BiFw9Z8s7aEeS',
            '38z8LRfDcGKMUxANkartYPVd3WCxnpEziwv68rGAWPbS',
          ],
        },
      })
    )
    setInterval(() => {
      ws.ping()
    }, 30000)
  })
  ws.on('message', res => {
    console.log('res:', res.toString('utf-8'))
  })
}
main()
  1. Example in 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": "tx",
        "args": {
            "pair": [
                "CzhUkaHFjo8s9sp2SuM6QMrV518pRsu3KmqKRhNvMLeN",
                "7P1f3rzUV9493vEoA7nbrEJoV9NnWfUaGePgjGUb6EX9",
                "7F1AHnpwqB6khEMj9iVNdWXB5MTrLjYrQy8msj57rpZ7",
                "343R8XMAqqGAkLpECaxwjH1Zi7a83mindmmpQS5uCvrF",
                "12oPgdnCCNxanJsXCo68p1XjNLqvaA9BiFw9Z8s7aEeS",
                "38z8LRfDcGKMUxANkartYPVd3WCxnpEziwv68rGAWPbS"
            ]
        }
    }

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

Request Example

{
	"method": "subscribe",
	"type": "tx",
	"args": {
		"pair": [
			"CzhUkaHFjo8s9sp2SuM6QMrV518pRsu3KmqKRhNvMLeN",
			"7P1f3rzUV9493vEoA7nbrEJoV9NnWfUaGePgjGUb6EX9",
			"7F1AHnpwqB6khEMj9iVNdWXB5MTrLjYrQy8msj57rpZ7",
			"343R8XMAqqGAkLpECaxwjH1Zi7a83mindmmpQS5uCvrF",
			"12oPgdnCCNxanJsXCo68p1XjNLqvaA9BiFw9Z8s7aEeS",
			"38z8LRfDcGKMUxANkartYPVd3WCxnpEziwv68rGAWPbS"
		]
	}
}

Request Response

{
	"status": "ack",
	"method": "subscribeResponse",
	"result": {
		"type": "tx",
		"t": 1751008703051,
		"subscribed": [
			"tx"
		],
		"message": "Connected and subscribed"
	}
}

Request Parameters

  • method: Action performed: "subscribe" for subscription, "unsubscribe" for unsubscription

  • type: 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

  • pair: Subscribed pair address

Last updated