Skip to content

Instantly share code, notes, and snippets.

@maxgfr
Created May 20, 2020 17:02
Show Gist options
  • Save maxgfr/a557864c520c46c16cce829e8f793a2d to your computer and use it in GitHub Desktop.
Save maxgfr/a557864c520c46c16cce829e8f793a2d to your computer and use it in GitHub Desktop.
Example of node application using kraken websocket
const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.kraken.com');
ws.on('open', function open() {
ws.send(JSON.stringify({
"event": "subscribe",
"pair": [
"BTC/USD",
"ETH/USD",
"XRP/USD"
],
"subscription": {
"name": "ticker"
}
}));
});
ws.on('message', function incoming(data) {
var arr = JSON.parse(data)
if(arr[1]) {
console.log(new Date())
console.log('for ' + arr[3])
// console.log(arr[1])
console.log('y a un mec qui prend à '+arr[1].a[0])
console.log('y a un mec qui vend à '+arr[1].b[0])
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment