Skip to content

Instantly share code, notes, and snippets.

@pixelomo
Last active June 11, 2021 06:54
Show Gist options
  • Save pixelomo/973f461d2d172b988560d77e68f450ba to your computer and use it in GitHub Desktop.
Save pixelomo/973f461d2d172b988560d77e68f450ba to your computer and use it in GitHub Desktop.
const cryptoWS = new WebSocket(`wss://mZ3Zq4NXbp.finage.ws:6002/?token=${process.env.FINAGE_SOCKET_KEY}`);
const indicesWS = new WebSocket(`wss://8umh1cipe9.finage.ws:9001/?token=${process.env.FINAGE_SOCKET_KEY}`);
cryptoWS.onopen = () => {
cryptoWS.send(JSON.stringify({"action": "subscribe", "symbols": "BTCUSD,ETHUSD,IOTAUSD,ADAUSD,XRPUSD,DOTUSD,DOGEUSD"}))
}
cryptoWS.onmessage = (msg) => {
let data = JSON.parse(msg.data);
console.log(data)
}
// {"status_code":200,"message":"Connected to the Cryptocurrency Market source."}
// {"s":"ADAUSD","p":"1.54090000","q":"7.60000000","dc":"0.7463","dd":"0.0115","t":1623388336875}
// {"s":"DOTUSD","p":"23.09900000","q":"9.85500000","dc":"1.8009","dd":"0.4160","t":1623388337371}
// Data streams showing all symbols...
indicesWS.onopen = () => {
indicesWS.send(JSON.stringify({"action": "subscribe", "symbols": "DJI,GSPC,IXIC,GDAXI,N225,IBEX,FTSE,XU100,DXY"}));
}
indicesWS.onmessage = (msg) => {
let data = JSON.parse(msg.data);
console.log(data)
}
// {"message": "Connected to the server."}
// {"status": "Success", "message": "N225 received."}
// Each symbol returns this success status
// Nothing after this...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment