Skip to content

Commit

Permalink
added promise support for all methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dutu committed Oct 13, 2020
1 parent 945aff5 commit 16e6a72
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 83 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.8.0 (2020-10-13)

* Add promise support for all methods. When `callback` parameter is not provided, the methods return a promise

### 1.7.1

* Parse Luno API errors
Expand Down
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build Status](https://travis-ci.org/bausmeier/node-bitx.png)](https://travis-ci.org/bausmeier/node-bitx)
[![codecov](https://codecov.io/gh/bausmeier/node-bitx/branch/master/graph/badge.svg)](https://codecov.io/gh/bausmeier/node-bitx)

A simple wrapper for the Luno API.
A simple wrapper for the Luno API. The module supports promise and callbacks.

## Usage
Add bitx as a dependency:
Expand All @@ -14,7 +14,7 @@ $ npm install --save bitx
### BitX([keyId, keySecret, ][options])
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:
The optional `options` argument can be used to override the default options. The default options are equivalent to:

```javascript
{
Expand All @@ -32,9 +32,11 @@ 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:

1. An error or `null` if no error occurred.
1. An object containing the data returned by the BitX API.
1. An object containing the data returned by the Luno API.

### getTicker([options, ]callback)
The `callback` function is optional. If the `callback` is not provided, the methods return a promise.

### getTicker([options, ][callback])
GET https://api.luno.com/api/1/ticker/XBTZAR

Default options:
Expand All @@ -51,7 +53,7 @@ Example:
bitx.getTicker(function(err, ticker) {});
```

### getAllTickers(callback)
### getAllTickers([callback])
GET https://api.luno.com/api/1/tickers

Example:
Expand All @@ -60,7 +62,7 @@ Example:
bitx.getAllTickers(function(err, tickers) {});
```

### getOrderBook([options, ]callback)
### getOrderBook([options, ][callback])
GET https://api.luno.com/api/1/orderbook

Default options:
Expand All @@ -77,7 +79,7 @@ Example:
bitx.getOrderBook(function(err, orderBook) {});
```

### getTrades([options, ]callback)
### getTrades([options, ][callback])
GET https://api.luno.com/api/1/trades

Default options:
Expand All @@ -94,7 +96,7 @@ Example:
bitx.getTrades(function(err, trades) {});
```

### getTradeList([options, ]callback)
### getTradeList([options, ][callback])
GET https://api.luno.com/api/1/listtrades

Default options:
Expand All @@ -111,7 +113,7 @@ Example:
bitx.getTradeList({sort_desc: true, limit: 10}, function(err, tradeList) {});
```

### getOrderList([options, ]callback)
### getOrderList([options, ][callback])
GET https://api.luno.com/api/1/listorders

Default options:
Expand All @@ -129,7 +131,7 @@ Example:
bitx.getOrderList({state: 'PENDING'}, function(err, orderList) {});
```

### getBalance([asset, ]callback)
### getBalance([asset, ][callback])
GET https://api.luno.com/api/1/balance

Example:
Expand All @@ -138,7 +140,7 @@ Example:
bitx.getBalance('ZAR', function(err, balance) {});
```

### getFundingAddress(asset, [options, ]callback)
### getFundingAddress(asset, [options, ][callback])
GET https://api.luno.com/api/1/funding_address

Default options:
Expand All @@ -155,7 +157,7 @@ Example:
bitx.getFundingAddress('XBT', {address: 'B1tC0InExAMPL3fundIN6AdDreS5t0Use'}, function(err, fundingAddress) {});
```

### createFundingAddress(asset, callback)
### createFundingAddress(asset, [callback])
POST https://api.luno.com/api/1/funding_address

Example:
Expand All @@ -164,7 +166,7 @@ Example:
bitx.createFundingAddress('XBT', function(err, fundingAddress) {});
```

### getFeeInfo([options, ]callback)
### getFeeInfo([options, ][callback])
GET https://api.luno.com/api/1/fee_info

Default options:
Expand All @@ -181,7 +183,7 @@ Example:
bitx.getFeeInfo({pair: 'XBTZAR'}, function(err, feeInfo) {});
```

### postBuyOrder(volume, price, [options, ]callback)
### postBuyOrder(volume, price, [options, ][callback])
POST https://api.luno.com/api/1/postorder

Example:
Expand All @@ -190,7 +192,7 @@ Example:
bitx.postBuyOrder(9999.99, 0.01, function(err, order) {});
```

### postSellOrder(volume, price, [options, ]callback)
### postSellOrder(volume, price, [options, ][callback])
POST https://api.luno.com/api/1/postorder

Example:
Expand All @@ -199,7 +201,7 @@ Example:
bitx.postSellOrder(0.01, 9999.99, function(err, order) {});
```

### postMarketBuyOrder(volume, [options, ]callback)
### postMarketBuyOrder(volume, [options, ][callback])
POST https://api.luno.com/api/1/marketorder

Example:
Expand All @@ -208,7 +210,7 @@ Example:
bitx.postMarketBuyOrder(0.01, function(err, order) {});
```

### postMarketSellOrder(volume, [options, ]callback)
### postMarketSellOrder(volume, [options, ][callback])
POST https://api.luno.com/api/1/marketorder

Example:
Expand All @@ -217,7 +219,7 @@ Example:
bitx.postMarketSellOrder(0.01, function(err, order) {});
```

### stopOrder(orderId, callback)
### stopOrder(orderId, [callback])
POST https://api.luno.com/api/1/stoporder

Example:
Expand All @@ -226,7 +228,7 @@ Example:
bitx.stopOrder('BXMC2CJ7HNB88U4', function(err, result) {});
```

### getOrder(orderId, callback)
### getOrder(orderId, [callback])
GET https://api.luno.com/api/1/orders/{orderId}

Example:
Expand All @@ -235,7 +237,7 @@ Example:
bitx.getOrder('BXHW6PFRRXKFSB4', function(err, result) {});
```

### getTransactions(asset, [options, ]callback)
### getTransactions(asset, [options, ][callback])
GET https://api.luno.com/api/1/transactions

Default options:
Expand All @@ -252,7 +254,7 @@ Example:
bitx.getTransactions('XBT', {offset: 5, limit: 20}, function(err, transactions) {});
```

### getWithdrawals(callback)
### getWithdrawals([callback])
GET https://api.luno.com/api/1/withdrawals

Example:
Expand All @@ -261,7 +263,7 @@ Example:
bitx.getWithdrawals(function(err, withdrawals) {});
```

### getWithdrawal(withdrawalId, callback)
### getWithdrawal(withdrawalId, [callback])
GET https://api.luno.com/api/1/withdrawals/{withdrawalId}

Example:
Expand All @@ -270,7 +272,7 @@ Example:
bitx.getWithdrawal('1212', function(err, withdrawal) {});
```

### requestWithdrawal(type, amount, callback)
### requestWithdrawal(type, amount, [callback])
POST https://api.luno.com/api/1/withdrawals

Example:
Expand All @@ -279,7 +281,7 @@ Example:
bitx.requestWithdrawal('ZAR_EFT', 1000, function(err, withdrawal) {});
```

### cancelWithdrawal(withdrawalId, callback)
### cancelWithdrawal(withdrawalId, [callback])
DELETE https://api.luno.com/api/1/withdrawals/{withdrawalId}

Example:
Expand Down
Loading

0 comments on commit 16e6a72

Please sign in to comment.