
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
An unofficial node.js client for the wex.nz trade API including v3 public api methods(depth, fee, ticker, and trades).
node-wex is available as node-wex
on npm.
npm install node-wex
var WEX = require('node-wex'),
wexTrade = new WEX("YourApiKey", "YourSecret"),
// No need to provide keys if you're only using the public api methods.
wexPublic = new WEX();
// Public API method call.
// Note: Could use "wexTrade" here as well.
wexPublic.ticker("ltc_btc", function(err, data) {
console.log(err, data);
});
// Trade API method call.
wexTrade.getInfo(function(err, info) {
console.log(err, info);
});
The constructor supports an optional third parameter for passing in various options to override defaults, which can either be a hash of the overrides or a nonce generation function if that is the only override required.
When passed as a hash, the following options are supported:
https://wex.nz/tapi
https://wex.nz/api/2/
true
by default, but can be set to false
if desired, such as if wex.nz has problems with their SSL certificate again.var WEX = require('node-wex'),
HttpsAgent = require('agentkeepalive').HttpsAgent,
wexTrade = new WEX("YourApiKey", "YourSecret", {
agent: new HttpsAgent()
});
By default the module generates a nonce based on the current timestamp in seconds(can't use anything smaller than seconds since wex is capped at 4294967294 for nonces) as a means of providing a consistently increasing number, but for traders who want to possibly get in more than one trade api request per second per api key there is a way to do so by providing a nonce generation function as the nonce
option in an options hash provided as the third parameter to the constructor. Please don't abuse the service wex is providing though.
wex expects every nonce given to be greater than the previous one for each api key you have, this presents a big problem when trying to do multiple async calls with the same api key since there is no guarantee that the first api call will be processed before the second one and so on. Chaining calls synchronously(take a look at promises with q.js for help with that) or using multiple clients, each with their own API key are the only way around that problem.
var WEX = require('node-wex'),
fs = require('fs'),
currentNonce = fs.existsSync("nonce.json") ? JSON.parse(fs.readFileSync("nonce.json")) : 0,
// Provide a nonce generation function as the third parameter if desired.
// The function must provide a number that is larger than the one before and must not
// be larger than the 32-bit unsigned integer max value of 4294967294.
wex = new WEX("YourApiKey", "YourSecret", {
nonce: function() {
return ++currentNonce;
}
});
process.on('exit', function(code){
fs.writeFileSync("nonce.json", currentNonce);
process.exit();
});
process.on('SIGINT', process.exit);
wex.getInfo(function(err, info) {
console.log(err, info);
});
A method-by-method reference is available on the wiki.
This module is ISC licensed.
FAQs
wex.nz API client for node.js
The npm package node-wex receives a total of 838 weekly downloads. As such, node-wex popularity was classified as not popular.
We found that node-wex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.