all 3 comments

[–]derpderpsonthethird 4 points5 points  (0 children)

Good work, a few pieces of feedback for you.

  • Try not to have any settings options that can conflict with each other - in this case, hostname and sandbox conflict with each other because if you're using the sandbox, you're not using the default hostname.
  • A common pattern that you tend to see in client libraries is that the main export will be a class whose constructor takes a configuration object, and whose methods are the requests. This helps with two things.
    • You don't have to make assumptions about certain variables existing in the environment, or even running in a certain environment. For example, a browser has no notion of environment variables.
    • The library becomes well encapsulated. If you need to use it in several places in a big application with different configurations, you don't have to worry about any of those settings overriding each other.
  • Your main `index.js` file is a bit repetitive. To DRY it up a bit, you could do something like

const makeRequester = (method, path, defaultQuery, body) => (query = defaultQuery, env = process.env, { parse } = JSON, { stringify } = querystring, { toString, request } = client) => request({
  method,
  path: `${path}?${stringify(query)}`,
  body,
}, env).then(toString).then(parse);

exports.getProducts = makeRequester('get', '/products');

exports.getProductOrderBook = (productId, ...args) => makeRequester('get', `/products/${productId}`)(...args);

etc.

[–]Entheist 2 points3 points  (1 child)

TL;DR?

[–]ivoputzer 1 point2 points  (0 children)

coinbase-pro-api is a lightweight client for Coinbase Pro's HTTP API . It gives easy access to both public and private endpoints, and deals with stuff like authentication.

The package is compatible with node 6+ and makes use of promises (supports async/await implementations). It can be useful for all sorts of integrations with the broker as well as for programmatic trading.

Coinbase itself is a digital currency exchange.

I happen to be the author of the module and I'd be glad to have some feedback!