A simple wrapper for the Luno API. The module supports promise and callbacks.
This module is forked from https://github.com/bausmeier/node-bitx. Since the original repository is not maintained anymore, starting with version v2.0.0 this fork has been detached from original repository. It is now stand alone. Contributions are not pull-requested to original repository.
Add luno as a dependency:
$ npm install --save luno-api-node
To access the private Luno API methods you must supply your key id and key secret as the first two arguments. If you are only accessing the public API endpoints you can leave these two arguments out.
The optional options
argument can be used to override the default options. The default options are equivalent to:
{
hostname: 'api.luno.com',
port: 443,
ca: undefined,
pair: 'XBTZAR'
}
Gives the current rate per minute of API calls. The property is read only.
It can be used by applications to limit the API call rate to prevent HTTP error code 429
(too many requests) responses from Luno server.
See Luno API documentation for applicable rate limitations: https://www.luno.com/en/developers/api#tag/Rate-Limiting
API calls which result in error code
429
orErrTooManyRequests
are considered failed/unprocessed server request and are not added to theapiCallRate
counter
Example:
console.log(luno.apiCallRate)
For details about the API endpoints see https://www.luno.com/en/developers/api.
The arguments passed to the callback function for each method are:
- An error or
null
if no error occurred. - An object containing the data returned by the Luno API.
The callback
function is optional. If the callback
is not provided, the methods return a promise.
POST https://api.luno.com/api/1/accounts
Example:
luno.createAccount('XBT', 'Trading ACC', function (err, response) {})
PUT https://api.luno.com/api/1/accounts/{id}/name
Example:
luno.updateAccountName(12345, 'Trading ACC', function (err, response) {})
GET https://api.luno.com/api/1/accounts/{id}/pending
Example:
luno.listAccountPendingTransactions(12345, function (err, response) {})
GET https://api.luno.com/api/1/accounts/{id}/transactions
Example:
luno.listAccountTransactions(12345, 1, 1000, function (err, response) {})
GET https://api.luno.com/api/1/balance
Example:
luno.listAccountBalances(['XBT', 'ETH'], function (err, response) {})
GET https://api.luno.com/api/exchange/1/move
Example:
luno.getMove({ id: 18563829047 }, function (err, response) {})
POST https://api.luno.com/api/exchange/1/move
Example:
luno.move('10000', 12345, 12346, { client_move_id: 'mv-53960812' }, function (err, response) {})
GET https://api.luno.com/api/exchange/1/move/list_moves
Example:
luno.listMoves({ before: 1530865703508, limit: 986 }, function (err, response) {})
GET https://api.luno.com/api/1/ticker/XBTZAR
Default options:
{
pair: luno.pair
}
Example:
luno.getTicker(function (err, ticker) {})
GET https://api.luno.com/api/1/tickers
Example:
luno.getAllTickers(function (err, tickers) {})
GET https://api.luno.com/api/1/orderbook
Default options:
{
pair: luno.pair
}
Example:
luno.getOrderBook(function (err, orderBook) {})
GET https://api.luno.com/api/1/trades
Default options:
{
pair: luno.pair
}
Example:
luno.getTrades(function (err, trades) {})
GET https://api.luno.com/api/1/listtrades
Default options:
{
pair: luno.pair
}
Example:
luno.getTradeList({ sort_desc: true, limit: 10 }, function (err, tradeList) {})
GET https://api.luno.com/api/1/listorders
Default options:
{
pair: luno.pair,
state: undefined
}
Example:
luno.getOrderList({ state: 'PENDING' }, function (err, orderList) {})
GET https://api.luno.com/api/exchange/2/listorders
Default options:
{
pair: luno.pair,
state: undefined
}
Example:
luno.getOrderListV2({ closed: true }, function (err, orderList) {})
GET https://api.luno.com/api/exchange/3/order
Example:
luno.getOrderListV3({ id: 'BXMC2CJ7HNB88U4' }, function (err, orderList) {})
GET https://api.luno.com/api/1/balance
Example:
luno.getBalance('ZAR', function (err, balance) {})
GET https://api.luno.com/api/1/funding_address
Default options:
{
address: undefined
}
Example:
luno.getFundingAddress('XBT', { address: 'B1tC0InExAMPL3fundIN6AdDreS5t0Use' }, function (err, fundingAddress) {})
POST https://api.luno.com/api/1/funding_address
Example:
luno.createFundingAddress('XBT', function (err, fundingAddress) {})
GET https://api.luno.com/api/1/fee_info
Default options:
{
pair: luno.pair
}
Example:
luno.getFeeInfo({ pair: 'XBTZAR' }, function (err, feeInfo) {})
POST https://api.luno.com/api/1/postorder
Example:
luno.postBuyOrder(9999.99, 0.01, function (err, order) {})
POST https://api.luno.com/api/1/postorder
Example:
luno.postSellOrder(0.01, 9999.99, function (err, order) {})
POST https://api.luno.com/api/1/marketorder
Example:
luno.postMarketBuyOrder(0.01, function (err, order) {})
POST https://api.luno.com/api/1/marketorder
Example:
luno.postMarketSellOrder(0.01, function (err, order) {})
POST https://api.luno.com/api/1/stoporder
Example:
luno.stopOrder('BXMC2CJ7HNB88U4', function (err, result) {})
GET https://api.luno.com/api/1/orders/{orderId}
Example:
luno.getOrder('BXHW6PFRRXKFSB4', function (err, result) {})
GET https://api.luno.com/api/exchange/2/orders/{orderId}
Example:
luno.getOrderV2('BXHW6PFRRXKFSB4', function (err, result) {})
GET https://api.luno.com/api/exchange/3/orders/{orderId}
Example:
luno.getOrderV3({ id: 'BXMC2CJ7HNB88U4' }, function (err, result) {})
luno.getOrderV3({ client_order_id: 'lmt-53960812' }, function (err, result) {})
GET https://api.luno.com/api/1/transactions
Default options:
{
offset: 0,
limit: 10
}
Example:
luno.getTransactions('XBT', { offset: 5, limit: 20 }, function (err, transactions) {})
GET https://api.luno.com/api/1/withdrawals
Example:
luno.getWithdrawals(function (err, withdrawals) {})
GET https://api.luno.com/api/1/withdrawals/{withdrawalId}
Example:
luno.getWithdrawal('1212', function (err, withdrawal) {})
POST https://api.luno.com/api/1/withdrawals
Example:
luno.requestWithdrawal('ZAR_EFT', 1000, function (err, withdrawal) {})
DELETE https://api.luno.com/api/1/withdrawals/{withdrawalId}
Example:
luno.cancelWithdrawal('1212', function (err, withdrawal) {})
GET https://api.luno.com/api/exchange/1/transfers
Example:
luno.listTransfers(1212, { limit: 986 }, function (err, data) {})
Open a pull request or create an issue and help me improve it.