npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wex-nz

v1.0.0

Published

wex-nz =====

Downloads

4

Readme

wex-nz

An node.js client for the wex.nz trade api

Fort from (https://github.com/pskupinski/node-btc-e)

Thanks Preston Skupinski [email protected] about (Preston Skupinski [email protected])

Installation

wex-nz is available as wex-nz on npm.

npm install wex-nz

Usage

var WEXNZ = require('wex-nz'),
    wexnzTrade = new WEXNZ("YourApiKey", "YourSecret"),
    // No need to provide keys if you're only using the public api methods.
    wexnzPublic = new WEXNZ();

// Public API method call.
// Note: Could use "wexnzTrade" here as well.
wexnzPublic.ticker("ltc_btc", function(err, data) {
  console.log(err, data);
});

// Trade API method call.
wexnzTrade.getInfo(function(err, info) {
  console.log(err, info);
});

Options

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:

  • agent - The HTTPS agent to use when making requests
  • timeout - The timeout to use when making requests, defaults to 5 seconds
  • nonce - A nonce generation function (Custom nonce generation)
  • tapi_url - The base url to use when making trade api requests, defaults to https://wex.nz/tapi
  • public_url - The base url to use when making public api requests, defaults to https://wex.nz/api/3/
  • strict_ssl - true by default, but can be set to false if desired, such as if wex.nz has problems with their SSL certificate again.
var WEXNZ = require('wex-nz'),
    HttpsAgent = require('agentkeepalive').HttpsAgent,
    wexnzTrade = new WEXNZ("YourApiKey", "YourSecret", {
      agent: new HttpsAgent()
    });

Custom nonce generation

By default the module generates a nonce based on the current timestamp in seconds(can't use anything smaller than seconds since wex.nz 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.nz is providing though.

wex.nz 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 WEXNZ = require('wex-nz'),
    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.
    wexnz = new WEXNZ("YourApiKey", "YourSecret", {
      nonce: function() {
        return ++currentNonce;
      }
    });

process.on('exit', function(code){
  fs.writeFileSync("nonce.json", currentNonce);
  process.exit();
});
process.on('SIGINT', process.exit);

wexnz.getInfo(function(err, info) {
  console.log(err, info);
});

License

This module is ISC licensed.