v3.4.0: Integrate Cross Margin WebSocket API User Data Stream for Binance Node.js SDK
What's Changed
- feat(v3.4.0): integrate margin websocket api user data stream with automatic listen token refresh & resubscribe, bump eslint & jest by @tiagosiebler in https://github.com/tiagosiebler/binance/pull/645
Summary
- Adds complete integration for Binance's "listen token" workflow used for the cross margin user data stream (via WebSocket API), since the original mechanic is formally deprecated.
- Automatic token refresh before expiry, for seamless continuous connection to the cross margin user data stream.
- Automatic token expiration handling, in the rare event the SDK was unable to refresh the token before it expired.
- Automatic resubscribe, if the connection drops after you subscribed to the cross margin user data stream.
- Binance docs for margin user data stream: https://developers.binance.com/docs/margin_trading/trade-data-stream
- Bumped eslint to 10 (dev dependency, resolves a number of audit complaints)
- Bumped jest to 30 (dev dependency, resolves a number of audit complaints)
- Bumped minor node build version to LTS
The process for subscribing to the Cross Margin WebSocket API user data stream with this Binance Node.js SDK is very similar to the other WS API user data streams. Just be sure to use the wsKey for margin. The rest is automatic, including token refresh & expiry handling: https://github.com/tiagosiebler/binance/blob/master/examples/WebSockets/Private(userdata)/ws-userdata-wsapi-margin.ts#L183-L186