Subscribe Multi-Pair Updates (WS)
Subscribe Multi-Pair Updates: Credit Usage 0
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
X-API-KEY can be obtained in your "Dashboard", go to check: Dashboard
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
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: 'tokensInfo',
args: {
tokensInfoInterval: '1h',
tokens: [
{
pair: '4N389xaQ2jRWDxpXmzwUCEnCQHDcDfprCsTqEd2taPoU',
token: 'FMaopciCph2TyyQfo4V7sNJhVmadujCcDupefiCdpump',
},
{
pair: '4N389xaQ2jRWDxpXmzwUCEnCQHDcDfprCsTqEd2taPoU',
token: 'FMaopciCph2TyyQfo4V7sNJhVmadujCcDupefiCdpump',
},
],
},
})
)
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/data/ws/"
headers = {"x-api-key": "YOUR_API_KEY"}
msg = {
method: 'subscribe',
type: 'tokensInfo',
args: {
tokensInfoInterval: '1h',
tokens: [
{
pair: '4N389xaQ2jRWDxpXmzwUCEnCQHDcDfprCsTqEd2taPoU',
token: 'FMaopciCph2TyyQfo4V7sNJhVmadujCcDupefiCdpump',
},
{
pair: '4N389xaQ2jRWDxpXmzwUCEnCQHDcDfprCsTqEd2taPoU',
token: 'FMaopciCph2TyyQfo4V7sNJhVmadujCcDupefiCdpump',
},
],
},
},
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": "pairsInfo",
"args": {
"pairsInfoInterval": "1h",
"pairs": [
{
"pair": "4N389xaQ2jRWDxpXmzwUCEnCQHDcDfprCsTqEd2taPoU",
"token": "FMaopciCph2TyyQfo4V7sNJhVmadujCcDupefiCdpump"
},
{
"pair": "4N389xaQ2jRWDxpXmzwUCEnCQHDcDfprCsTqEd2taPoU",
"token": "FMaopciCph2TyyQfo4V7sNJhVmadujCcDupefiCdpump"
}
]
}
}
Request Response
{
"status": "ack",
"method": "subscribeResponse",
"result": {
"type": "pairsInfo",
"t": 1751008703051,
"subscribed": [
"pairsInfo"
],
"message": "Connected and subscribed"
}
}
Request Parameters
Last updated