Node (npm) API wrapper for Kraken Exchange
This a library that interacts with the Kraken Exchange APIInstallation
kraken-wrapper is available from npmnpm install kraken-wrapper
Usage
Getting Started
Include the module and create a new Kraken object.The parameters are optional and have the following values:
- apikey: (string) Your apps API KEY. Optional only needed for private methods
- apisecret: (string) Your apps API SECRET. Optional only needed for private methods
Example with API KEY and API SECRET for private and public methods:
const Kraken = require('kraken-wrapper');
const kraken = new Kraken('YOUR API KEY', 'YOUR API SECRET');
Example without API KEY and API SECRET for just public methods:const kraken = require('kraken-wrapper');
const kraken = new Kraken();
Once you have the client you can do request to the API like this:
const kraken = require('kraken-wrapper');
const kraken = new Kraken('YOUR API KEY', 'YOUR API SECRET');
kraken.getTrades({ pair: 'ETHUSD' }).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
All the methods always return a Promise.If the result has no errors the result object will be:
{
error: [],
result: []
}
How to obtain the API KEY and API SECRET
- Login on your Kraken account https://www.kraken.com/en-us/login
- Go to Settings > API
- Click on Generate New Key
- Fill the fields and add the permissions
- Click on Generate Key
- Copy your Key and Secret.
CAUTION
Depending on the permission that you give to your Keys you can make transactions and withdrawals with certains methods, always keep safe your KEYS, don't you put your Keys in the code. Use enviroment variables or other secure methods.WE ARE NOT RESPONSABLE FOR THE WRONG USE OF THIS APPLICATION OR FOR ANY MALFUNCTION, BREACH OR ANY OTHER PROBLEM WITH THE KRAKEN API.
YOU HAVE BEEN WARNED
Methods
All the method's params are objects.Public methods
- getTime() - Kraken Server's time - Returns a json object with the unix and rfc 1123 time, useful for approximating the skew time between the server and client.
- getAssetInfo(params) - Used to get an array of asset names and their info.
- getTradableAssetPairs(params) - Used to get an array pair names and their info
- getTickerInformation(params) - Used to get an array of pair names and their ticker info
- getOHLC(params) - Used to get an array of pair name and OHLC (Open, High, Low, Close) data.
- getOrderBook(params) - Used to get an array of pair name and market depth
- getTrades(params) - Used to get an array of pair name and recent trade data
- getSpread(params) - Used to get an array of pair name and recent spread data
Private methods (API KEY and SECRET required)
- getBalance() - Used to get an array of asset names and balance amount
- getTradeBalance(params) - Used to get an array of trade balance info
- getOpenOrders(params) - Used to get an array of order info in open array with txid as the key
- getClosedOrders(params) - Used to get an array of order info
- getQueryOrders(params) - Used to get a associative array of orders info
- getTradesHistory(params) - Used to get an array of trade info
- getQueryTrades(params) - Used to get a associative array of trades info
- getOpenPositions(params) - Used to get a associative array of open position info
- getLedgers(params) - Used to get a associative array of ledgers info
- getTradeVolume(params) - Used to get a associative array of ledgers info
- getQueryLedgers(params) - Used to get a associative array of trade volume info
- setAddOrder(params) - Used to request a new buy or sell order
- setCancelOrder(params) - Used to cancel a open buy or sell order
Private Experimental Methods
- getDepositMethods(params) - Used to get a associative array of deposit methods
- getDepositAddresses(params) - Used to get a associative array of deposit addresses or generate a new address.
- getDepositStatus(params) - Used to get a array of array deposit status information
- getWithdrawInfo(params) - Used to get a associative array of withdrawal info.
- setWithdraw(params) - Make a withdrawal
- getWithdrawStatus(params) - Get a array of array withdrawal status information.
- setWithdrawCancel(params) - Cancel a withdrawal. Cancelation cannot be guaranteed. This will put in a cancelation request. Depending upon how far along the withdrawal process is, it may not be possible to cancel the withdrawal.
If you want more info about the methods here you can find the documentation on the Kraken API documentation here.
Contribute
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D