-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
Hi.
We just upgrade @binance/spot v20.0.1 to binance/spot v23.0.1.
client.restAPI.newUserDataStream() does not working anymore.
So we can not generate listenkey for connecting to user data stream.
Where is the guide for new way ?
Errors:
Property 'newUserDataStream' does not exist on type 'RestAPI'.
Property 'putUserDataStream' does not exist on type 'RestAPI'.
Property 'deleteUserDataStream' does not exist on type 'RestAPI'.
Our Code:
const client = new Spot({
configurationRestAPI: {
apiKey: this.apiKey,
apiSecret: this.apiSecret,
basePath: this.baseURL
}
});
const response = await client.restAPI.startUserDataStream();
const data = await response.data();
const listenKey = data.listenKey || '';
console.log(`Created listen key: ${listenKey}`);
const wsUrl = this.isTestnet
? `wss://stream.testnet.binance.vision:9443/ws/${listenKey}`
: `wss://stream.binance.com:9443/ws/${listenKey}`;
this.userDataWs = new WebSocket(wsUrl);
console.log(`[BinanceClient] Connecting to user data stream: ${wsUrl}`);
this.userDataWs.on('open', () => {
console.log(`[BinanceClient] User data stream connected`);
});
this.userDataWs.on('message', (data: Buffer) => {
try {
const message = JSON.parse(data.toString());
console.log(`Received message: ${message}`);
} catch (error: any) {
console.error(`[BinanceClient] Error parsing user data message: ${error.message}`);
}
});
Metadata
Metadata
Assignees
Labels
No labels