Hello,
I’m trying to write a client javascript code (for browser) for fetching data for Web Socket User Data Stream. Based on documentation is not clear
- how to pass Security Key for getting a listenKey.
- how to get events data for Balance and Position update, Order update.
Please, help me modify the code below for getting Balance, Position, Order update through wss.
function OpenSocketBinance() {
var xhr = new XMLHttpRequest();
var listenKey = null;
//apiPath : 'https://testnet.binancefuture.com'
xhr.open("POST", apiPath + '/fapi/v1/listenKey/timestamp=', false);
xhr.setRequestHeader("X-MBX-APIKEY", apiKey);
xhr.send(null);
if (xhr.status === 200)
listenKey = (JSON.parse(xhr.responseText))['listenKey'];
// 'wss://stream.binancefuture.com'
ws = new WebSocket(`${wssPath}/ws/${listenKey}`);
//ws.setHandler('executionReport', (params) => log(params));
//ws.setHandler('outboundAccountInfo', (params) => log(params));
}