Node Bittrex API library - https://github.com/n0mad01/node.bittrex.api Bitterex Api Docs - https://bittrex.com/home/api
Fetch the project via git:
$ git clone https://github.com/peev/cryptobot.gitthen meet the package dependencies:
$ cd cryptobot/
$ npm installthen run the cryptobeast/app.js via nodemon VSCode node debuger:
$ nodemon cryptobeast/app.jsconst APIKEY = 'your_key';
const APISECRET = 'your_secret';By default the returned data by bittrex.node.api is an object, in order to get clear text you have to add the option cleartext (streams will always return text):
'cleartext' : trueThe baseUrl itself can also be set via options
'baseUrl' : 'https://bittrex.com/api/v1'following methods are implemented:
websockets.listen, websockets.subscribe
listen example
bittrex.websockets.listen( function( data ) {
if (data.M === 'updateSummaryState') {
data.A.forEach(function(data_for) {
data_for.Deltas.forEach(function(marketsDelta) {
console.log('Ticker Update for '+ marketsDelta.MarketName, marketsDelta);
});
});
}
});subscribe example
bittrex.websockets.subscribe(['BTC-ETH','BTC-SC','BTC-ZEN'], function(data) {
if (data.M === 'updateExchangeState') {
data.A.forEach(function(data_for) {
console.log('Market Update for '+ data_for.MarketName, data_for);
});
}
});To activate Streaming simply add to your options:
'stream' : trueAfter configuration you can use the object right away: example #1
bittrex.getmarketsummaries( function( data ) {
for( var i in data.result ) {
bittrex.getticker( { market : data.result[i].MarketName }, function( ticker ) {
console.log( ticker );
});
}
});example #2
bittrex.getbalance({ currency : 'BTC' }, function( data ) {
console.log( data );
});Websockets depends on the following npm packages:
- signalR websockets client https://www.npmjs.com/package/signalrjs
- jsonic JSON parser https://www.npmjs.com/package/jsonic
Streaming depends on the following npm packages (will be removed in future versions):
- JSONStream https://www.npmjs.org/package/JSONStream
- event-stream https://www.npmjs.org/package/event-stream
Other libraries utilized:
For HmacSHA512 this package is using a part of Googles Crypto.js (the node crypt package could not provide any appropriate result).
Optional parameters may have to be looked up at https://bittrex.com/Home/Api.
It may happen that some Bittrex API methods are missing, also they could have been forgotten in the documentation. In this case, if this strikes you, feel free to open a issue or send me a pull request.
Also: the method sendCustomRequest enables completely custom requests, regardless the specific API methods.
- url String
- callback Function
- credentials Boolean optional whether the credentials should be applied to the request/stream or not, default is set to false.
example #1
var url = 'https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC';
bittrex.sendCustomRequest( url, function( data ) {
console.log( data );
});example #2 (credentials applied to request/stream)
bittrex.sendCustomRequest( 'https://bittrex.com/api/v1.1/account/getbalances?currency=BTC', function( data ) {
console.log( data );
}, true );
will result in (the Header is being set too):
https://bittrex.com/api/v1.1/account/getbalances?currency=BTC&apikey=API_KEY&nonce=4456490600bittrex.getticker( { market : 'BTC-LTC' }, function( data ) {
console.log( data );
});bittrex.getbalances( function( data ) {
console.log( data );
});bittrex.getmarkethistory({ market : 'BTC-LTC' }, function( data ) {
console.log( data );
});bittrex.getmarketsummaries( function( data ) {
console.log( data );
});bittrex.getmarketsummary( { market : 'BTC-LTC'}, function( data ) {
console.log( data );
});bittrex.getorderbook({ market : 'BTC-LTC', depth : 10, type : 'both' }, function( data ) {
console.log( data );
});bittrex.getwithdrawalhistory({ currency : 'BTC' }, function( data ) {
console.log( data );
});bittrex.getdepositaddress({ currency : 'BTC' }, function( data ) {
console.log( data );
});bittrex.getdeposithistory({ currency : 'BTC' }, function( data ) {
console.log( data );
});bittrex.getbalance({ currency : 'BTC' }, function( data ) {
console.log( data );
});bittrex.withdraw({ currency : 'BTC', quantity : '1.5112', address : 'THE_ADDRESS' }, function( data ) {
console.log( data );
});BTC
17gtixgt4Q8hZcSictQwj5WUdgFjegCt36