Skip to content

Instantly share code, notes, and snippets.

@YasunoriMATSUOKA
Created April 4, 2020 01:41
Show Gist options
  • Save YasunoriMATSUOKA/ae9b5ff3eb617d14db60d1e6adeb5179 to your computer and use it in GitHub Desktop.
Save YasunoriMATSUOKA/ae9b5ff3eb617d14db60d1e6adeb5179 to your computer and use it in GitHub Desktop.
const url = "wss://ws.zaif.jp/stream?currency_pair=btc_jpy"
const WebSocket = require('ws')
const wss = new WebSocket(url)
wss.on('open', () => {
console.log('Connection open')
})
wss.on('close', () => {
console.log('Connection close')
})
wss.on('message', (dataString) => {
console.log('New message')
const json = JSON.parse(dataString)
console.log(json)
})
setTimeout(() => {
wss.terminate()
}, 10000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment