how can I get live stream from binance web-socket. anyone know about that?
I tried his documentation but I can not understand properly https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md#subscribe-to-a-stream above his documentation link
try this documentation MarketStream
There are many ways to do this, one of them is the following example:
const binanceSocket = new WebSocket("wss://stream.binance.com:9443/ws/!miniTicker@arr");
binanceSocket.onmessage = function (event) {
const messageObject = JSON.parse(event.data);
$("." + messageObject[0].s).html(messageObject[0].c);
messageObject.forEach(function (item, index) {
if (item.s === 'BTCUSDT') {
let btcValue = parseFloat(item.c);
$("#btcValue").html("BTC: $" + btcValue.toFixed(2));
}
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.