skylinezum / node-coinigy

Node wrapper for Coinigy's REST API
MIT License
18 stars 7 forks source link

Body from client side + other thing I noticed. #4

Closed jdieks closed 7 years ago

jdieks commented 7 years ago

Hi, this is a super n00b question, I'm building a coinigy bot as the first thing I've programmed in almost 20 years :)

I really like what you have done. There are 2 things that I have come across from your "use" example.

1) var Coinigy = require('node-coinigy'); var coinigy = new Coinigy('your-api-key', 'your-api-secret');

coinigy.activity() .then(function (body) { console.log(body.data); console.log(body.notifications); }) .catch(function (err) { console.log(err); });

Those console log commands did not work for me. I ran into this exact issue: https://stackoverflow.com/questions/10729276/how-can-i-get-the-full-object-in-node-jss-console-log-rather-than-object

So to make it work I had to change it to this:

const util = require('util') coinigy.activity() .then(function (body) { console.log(util.inspect(body.data, false, null)); console.log(util.inspect(body.notifications, false, null)); }) .catch(function (err) { console.log(err); });

The other thing is that I want to read the tickers now, so I want to do something like this:

const util = require('util') coinigy.ticker() .then(function (body) { console.log(util.inspect(body.data, false, null)); console.log(util.inspect(body.notifications, false, null)); }) .catch(function (err) { console.log(err); });

But I don't understand how I should implement this bit: {exchange_code, exchange_market} Thanks for the help! :)

skylinezum commented 7 years ago

Hi, Thanks for using this library.

To address point 1 I don't want to add any opinionated code to the logging function as there are many different ways that people log more than 2 levels. It's more of an example of how to use the library. I assume user will decide on their own with their own preferences.

To add the params, create an object with those fields with the keys listed

coinigy.ticker({
  exchange_code: 'GDAX',
  exchange_market: 'BTC/USD'
})
.then(function (body) {
console.log(util.inspect(body.data, false, null));
console.log(util.inspect(body.notifications, false, null));
})
.catch(function (err) {
console.log(err);
});
jdieks commented 7 years ago

Thanks, I was typing out "bittrex" in full instead of "BTRX". That seemed to be the problem! :)