A Node.js API client for the [https://github.com/ionic-team/ionic][Ionic Framework].
The client supports public and private calls.
For private calls, the user secret is never exposed to other parts of the program or over the Web. The user key is sent as a header to the API, along with a signed request.
Repo home: [github.com/leandronascimento/api-bittrex][repo]
This Library was created by using parts of Adrian Soluch (@n0mad01) soluch.us [node.bittrex.api] (https://github.com/n0mad01/node.bittrex.api/blob/master/node.bittrex.api.js) MIT, open source. See LICENSE file.
This is just a quick reminder that you are handling coins with this library (and thus real money), so, understand the situation as much as possible and make everything to prevent losing them.
Here is a small checklist you should go through before you start:
- Make sure you don't give your api key more rights as absolutely necessary - for first testing READ INFO alone should be enough! (bittrex.com under: Settings/API Keys)
- make sure to understand the API Key permissions
- READ INFO - Allows you to read private details such as open orders, order history, balances, etc
- TRADE LIMIT - Allows you to create/cancel trade limit buy/sell orders
- TRADE MARKET - allows you to create/cancel market buy/sell orders
- WITHDRAW - Allows you to withdraw to another address
- Make use of the Bittrex IP Whitelist as also the Withdrawal Whitelist features
- Do not ever commit your API Keys to GitHub or expose them under any circumstances!
$ npm install api-bittrex
In your app, import the module:
import * as bittrex from 'api-bittrex';
If only public API calls are needed, then no API key or secret is required:
const APISECRET = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const APIKEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
bittrex.options({
'apikey' : APIKEY,
'apisecret' : APISECRET,
'stream' : false,
'verbose' : false,
'cleartext' : false
});
bittrex.getbalances( function( data, err ) {
console.log( data );
});
After configuration you can use the object right away: example #1
bittrex.getmarketsummaries( function( data, err ) {
if (err) {
return console.error(err);
}
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, err ) {
if (err) {
return console.error(err);
}
console.log( data );
});
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, err ) {
console.log( data );
});
example #2 (credentials applied to request/stream)
bittrex.sendCustomRequest( 'https://bittrex.com/api/v1.1/account/getbalances?currency=BTC', function( data, err ) {
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=4456490600
bittrex.getticker( { market : 'BTC-LTC' }, function( data, err ) {
console.log( data );
});
bittrex.getbalances( function( data, err ) {
console.log( data );
});
bittrex.getmarkethistory({ market : 'BTC-LTC' }, function( data, err ) {
console.log( data );
});
bittrex.getcandles({
marketName: 'USDT-BTC',
tickInterval: 'fiveMin', // intervals are keywords
}, function( data, err ) {
console.log( data );
});
bittrex.getmarketsummaries( function( data, err ) {
console.log( data );
});
bittrex.getmarketsummary( { market : 'BTC-LTC'}, function( data, err ) {
console.log( data );
});
bittrex.getorderbook({ market : 'BTC-LTC', depth : 10, type : 'both' }, function( data, err ) {
console.log( data );
});
bittrex.getwithdrawalhistory({ currency : 'BTC' }, function( data, err ) {
console.log( data );
});
bittrex.getdepositaddress({ currency : 'BTC' }, function( data, err ) {
console.log( data );
});
bittrex.getdeposithistory({ currency : 'BTC' }, function( data, err ) {
console.log( data );
});
bittrex.getbalance({ currency : 'BTC' }, function( data, err ) {
console.log( data );
});
bittrex.withdraw({ currency : 'BTC', quantity : '1.5112', address : 'THE_ADDRESS' }, function( data, err ) {
console.log( data );
});