bitmex-realtime-api
Advanced tools
Comparing version 0.5.0 to 0.5.1
13
index.js
@@ -12,5 +12,9 @@ const _ = require('lodash'); | ||
const endpoints = { | ||
production: 'wss://www.bitmex.com/realtime', | ||
testnet: 'wss://testnet.bitmex.com/realtime' | ||
production: 'wss://ws.bitmex.com/realtime', | ||
testnet: 'wss://ws.testnet.bitmex.com/realtime' | ||
}; | ||
const httpEndpoints = { | ||
production: 'https://www.bitmex.com/api/v1', | ||
testnet: 'https://testnet.bitmex.com/api/v1' | ||
} | ||
const noSymbolTables = BitMEXClient.noSymbolTables = [ | ||
@@ -49,2 +53,5 @@ 'account', | ||
} | ||
if (!options.httpEndpoint) { | ||
options.httpEndpoint = options.testnet ? httpEndpoints.testnet : httpEndpoints.production; | ||
} | ||
if (process.env.BITMEX_ENDPOINT) options.endpoint = process.env.BITMEX_ENDPOINT; | ||
@@ -62,3 +69,3 @@ debug(options) | ||
// Get valid streams so we can validate our subscriptions. | ||
getStreams(options.endpoint, function(err, streams) { | ||
getStreams(options.httpEndpoint, function(err, streams) { | ||
if (err) throw err; | ||
@@ -65,0 +72,0 @@ emitter.initialized = true; |
@@ -36,2 +36,5 @@ const _ = require('lodash'); | ||
try { | ||
if (data === "pong") { | ||
return; | ||
} | ||
data = JSON.parse(data); | ||
@@ -38,0 +41,0 @@ debug('Received %j', data); |
const superagent = require('superagent'); | ||
const url = require('url'); | ||
const debug = require('debug')('BitMEX:realtime-api:getStreams'); | ||
module.exports = function(wsEndpoint, callback) { | ||
const parsed = url.parse(wsEndpoint); | ||
const httpEndpoint = url.format({ | ||
protocol: parsed.protocol === 'wss:' ? 'https:' : 'http', | ||
host: parsed.host | ||
}); | ||
module.exports = function(httpEndpoint, callback) { | ||
superagent | ||
.get(httpEndpoint + '/api/v1/schema/websocketHelp') | ||
.get(httpEndpoint + '/schema/websocketHelp') | ||
.end(function(err, res) { | ||
@@ -15,0 +8,0 @@ if (err) return callback(err); |
{ | ||
"name": "bitmex-realtime-api", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "A library for interacting with BitMEX's websocket API.", | ||
@@ -26,3 +26,3 @@ "main": "index.js", | ||
"eventemitter2": "^6.4.3", | ||
"lodash": "^4.17.20", | ||
"lodash": "^4.17.21", | ||
"superagent": "^6.1.0", | ||
@@ -29,0 +29,0 @@ "ws": "^7.3.1" |
@@ -136,1 +136,11 @@ ### Node.JS Adapter for BitMEX Realtime Data | ||
``` | ||
### Heartbeat | ||
https://www.bitmex.com/app/wsAPI#Heartbeats | ||
you can implement a more thorough solution, but hope this helps along | ||
``` | ||
setInterval(() => { | ||
client.socket.send("ping") | ||
}, 30 * 1000); // sends ping every 30 s | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31635
686
145
1
Updatedlodash@^4.17.21