binance
binance copied to clipboard
Connecting websockets to Binance.US
I see that on the REST API, the endpoint can be set to Binance.US. What about the WebSockets API, can it be used on Binance.US as well?
This should be possible using the new client implementations in #122. The websockets API exposes a method to connect to a full websocket URL, or you could look at expanding support for the US servers in the existing implementation.
Take a look at how getWsBaseUrl
is hooked up in these utility methods:
https://github.com/tiagosiebler/binance/blob/v2.0.0/beta/src/websocket-client.ts#L774-L781
Sorry, late response (I was on vacation). Thanks for confirming this is now possible. So the following is the recommended way of doing this, right?
wsClient = new WebsocketClient({
api_key: apiKey,
api_secret: apiSecret,
beautify: true,
wsUrl: <Binance US ws URL goes here>,
}, logger);
@hodlerhacks
Yup, i am able to get it to work using binance us:
let client = new WebsocketClient({
wsUrl: 'wss://stream.binance.us:9443',
api_key: process.env.BINANCE_REAL_KEY,
api_secret: process.env.BINANCE_REAL_SECRET,
beautify: true
})