Bitmex API installation

Let’s discuss our different approaches of installing the bitmex api.

I use Javascript and npm.

I wanted to install the API and test it with the simple function userGetMargin, but unfortunately the “BitMexApi” in the fourth line always gets the error “BitMexApi is not a constructor”.

After doing some research some articles suggested that we could delete the “new” before the “BitMexApi”, but if we delete the “new”, the error “BitMexApi is not a function” is shown instead by Windows Powershell.

How have you approached the installation part so far?

Best regards,

Frederik

var BitMexApi = require(“bit_mex_api”);
const apiKey = “insert api key here”;
const secret = “insert secret key here”;

var apiInstance = new BitMexApi ({apiKey, secret, testnet:true});

var opts = {
‘currency’: “XBt” // String |
};

var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API erfolgreich kontaktiert. Zurückgekommen: ’ + data);
}
};

apiInstance.userGetMargin(opts, callback);

2 Likes