How to set take profit and stop loss for market order

Hi, I use JavaScript and I already used other trading APIs where I can set a take profit and stop loss for my positions
How to do the same with Binance API? Also what is the best JS library for using Binance REST Api? And why Binance has a rest API while most modern brokers rely on sockets for everything which is much faster and reliable than http?

Thanks

This is the an official library supported by Binance (GitHub - binance/binance-connector-node: A simple connector to Binance Public API). You can place a stop loss and take profit using the order endpoint (binance-connector-node/newOrder.js at master · binance/binance-connector-node · GitHub), it has to be used in combination with the stopPrice parameter, you can read more about it here. (Binance API Documentation)