How can I use tickers for multiple tokens?

How can I perform actions for multiple tokens, for example, if I have many tickers and for each pair I need specific actions, where in the code should I handle the data? I couldn’t find a solution in the documentation.

This code doesn’t work.

websocketStreamClient.ticker('bnbusdt', () => {
  console.log('bnbusdt data')
})

The code from the documentation:

const { WebsocketStream } = require('@binance/connector')
const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const callbacks = {
  open: () => logger.debug('Connected with Websocket server'),
  close: () => logger.debug('Disconnected with Websocket server'),
  message: data => logger.info(data)
}

const websocketStreamClient = new WebsocketStream({ logger, callbacks })
websocketStreamClient.ticker('bnbusdt')
setTimeout(() => websocketStreamClient.disconnect(), 6000)

Hey,

I would suggest you check out the example in the library.
You can update the code as follows:

const { Console } = require('console')
const WebsocketStream = require('@binance/connector')

const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const callbacks = {
  open: () => logger.debug('Connected with Websocket server'),
  close: () => logger.debug('Disconnected with Websocket server'),
  message: data => logger.info(data)
}

// Connect to websocket server in combine mode, the stream name will be returned in response messages
const websocketStreamClient = new WebsocketStream({ logger, callbacks, combinedStreams: true })

// subscribe to bnbusdt kline stream
websocketStreamClient.kline('bnbusdt', '1m')

// subscribe to ethusdt kline stream
setTimeout(() => { websocketStreamClient.kline('ethusdt', '1m') }, 3000)

// subscribe to btcusdt kline stream
setTimeout(() => { websocketStreamClient.kline('btcusdt', '1m') }, 3000)

// disconnect from websocket server
setTimeout(() => websocketStreamClient.disconnect(), 10000)