Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matefs/92709028f03b9dc2861fdbb76b092ba4 to your computer and use it in GitHub Desktop.
Save matefs/92709028f03b9dc2861fdbb76b092ba4 to your computer and use it in GitHub Desktop.
bitcoin pricing real time ( binance api websocket api )
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