Skip to content

Instantly share code, notes, and snippets.

@coinables
Created June 20, 2017 03:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coinables/4439cb74a6b7763eeb4a916393535acf to your computer and use it in GitHub Desktop.
Save coinables/4439cb74a6b7763eeb4a916393535acf to your computer and use it in GitHub Desktop.
coincap.io with socket.io example
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
</head>
<body>
<script type="text/javascript">
var socket = io.connect('http://socket.coincap.io');
socket.on('trades', function (tradeMsg) {
console.log(tradeMsg);
if(tradeMsg.message.coin == "ETH"){
document.getElementById("ETH").innerHTML = tradeMsg.message.msg.price;
}
})
</script>
ETH:
<div id="ETH"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment