Created
August 26, 2024 15:06
-
-
Save matefs/92709028f03b9dc2861fdbb76b092ba4 to your computer and use it in GitHub Desktop.
bitcoin pricing real time ( binance api websocket api )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const socket = new WebSocket('wss://stream.binance.com:9443/ws/btcusdt@trade'); | |
socket.onmessage = (event) => { | |
const data = JSON.parse(event.data); | |
const btcPriceUSD = parseFloat(data.p); | |
console.log("Bitcoin pricing in USD (WebSocket):", btcPriceUSD); | |
}; | |
// code tested and working in 26/08/2024 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment