Skip to content

Commit 16e6a72

Browse files
committed
added promise support for all methods
1 parent 945aff5 commit 16e6a72

File tree

4 files changed

+114
-83
lines changed

4 files changed

+114
-83
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 1.8.0 (2020-10-13)
2+
3+
* Add promise support for all methods. When `callback` parameter is not provided, the methods return a promise
4+
15
### 1.7.1
26

37
* Parse Luno API errors

README.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Build Status](https://travis-ci.org/bausmeier/node-bitx.png)](https://travis-ci.org/bausmeier/node-bitx)
33
[![codecov](https://codecov.io/gh/bausmeier/node-bitx/branch/master/graph/badge.svg)](https://codecov.io/gh/bausmeier/node-bitx)
44

5-
A simple wrapper for the Luno API.
5+
A simple wrapper for the Luno API. The module supports promise and callbacks.
66

77
## Usage
88
Add bitx as a dependency:
@@ -14,7 +14,7 @@ $ npm install --save bitx
1414
### BitX([keyId, keySecret, ][options])
1515
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.
1616

17-
The optional options argument can be used to override the default options. The default options are equivalent to:
17+
The optional `options` argument can be used to override the default options. The default options are equivalent to:
1818

1919
```javascript
2020
{
@@ -32,9 +32,11 @@ For details about the API endpoints see https://www.luno.com/en/developers/api.
3232
The arguments passed to the callback function for each method are:
3333

3434
1. An error or `null` if no error occurred.
35-
1. An object containing the data returned by the BitX API.
35+
1. An object containing the data returned by the Luno API.
3636

37-
### getTicker([options, ]callback)
37+
The `callback` function is optional. If the `callback` is not provided, the methods return a promise.
38+
39+
### getTicker([options, ][callback])
3840
GET https://api.luno.com/api/1/ticker/XBTZAR
3941

4042
Default options:
@@ -51,7 +53,7 @@ Example:
5153
bitx.getTicker(function(err, ticker) {});
5254
```
5355

54-
### getAllTickers(callback)
56+
### getAllTickers([callback])
5557
GET https://api.luno.com/api/1/tickers
5658

5759
Example:
@@ -60,7 +62,7 @@ Example:
6062
bitx.getAllTickers(function(err, tickers) {});
6163
```
6264

63-
### getOrderBook([options, ]callback)
65+
### getOrderBook([options, ][callback])
6466
GET https://api.luno.com/api/1/orderbook
6567

6668
Default options:
@@ -77,7 +79,7 @@ Example:
7779
bitx.getOrderBook(function(err, orderBook) {});
7880
```
7981

80-
### getTrades([options, ]callback)
82+
### getTrades([options, ][callback])
8183
GET https://api.luno.com/api/1/trades
8284

8385
Default options:
@@ -94,7 +96,7 @@ Example:
9496
bitx.getTrades(function(err, trades) {});
9597
```
9698

97-
### getTradeList([options, ]callback)
99+
### getTradeList([options, ][callback])
98100
GET https://api.luno.com/api/1/listtrades
99101

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

114-
### getOrderList([options, ]callback)
116+
### getOrderList([options, ][callback])
115117
GET https://api.luno.com/api/1/listorders
116118

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

132-
### getBalance([asset, ]callback)
134+
### getBalance([asset, ][callback])
133135
GET https://api.luno.com/api/1/balance
134136

135137
Example:
@@ -138,7 +140,7 @@ Example:
138140
bitx.getBalance('ZAR', function(err, balance) {});
139141
```
140142

141-
### getFundingAddress(asset, [options, ]callback)
143+
### getFundingAddress(asset, [options, ][callback])
142144
GET https://api.luno.com/api/1/funding_address
143145

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

158-
### createFundingAddress(asset, callback)
160+
### createFundingAddress(asset, [callback])
159161
POST https://api.luno.com/api/1/funding_address
160162

161163
Example:
@@ -164,7 +166,7 @@ Example:
164166
bitx.createFundingAddress('XBT', function(err, fundingAddress) {});
165167
```
166168

167-
### getFeeInfo([options, ]callback)
169+
### getFeeInfo([options, ][callback])
168170
GET https://api.luno.com/api/1/fee_info
169171

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

184-
### postBuyOrder(volume, price, [options, ]callback)
186+
### postBuyOrder(volume, price, [options, ][callback])
185187
POST https://api.luno.com/api/1/postorder
186188

187189
Example:
@@ -190,7 +192,7 @@ Example:
190192
bitx.postBuyOrder(9999.99, 0.01, function(err, order) {});
191193
```
192194

193-
### postSellOrder(volume, price, [options, ]callback)
195+
### postSellOrder(volume, price, [options, ][callback])
194196
POST https://api.luno.com/api/1/postorder
195197

196198
Example:
@@ -199,7 +201,7 @@ Example:
199201
bitx.postSellOrder(0.01, 9999.99, function(err, order) {});
200202
```
201203

202-
### postMarketBuyOrder(volume, [options, ]callback)
204+
### postMarketBuyOrder(volume, [options, ][callback])
203205
POST https://api.luno.com/api/1/marketorder
204206

205207
Example:
@@ -208,7 +210,7 @@ Example:
208210
bitx.postMarketBuyOrder(0.01, function(err, order) {});
209211
```
210212

211-
### postMarketSellOrder(volume, [options, ]callback)
213+
### postMarketSellOrder(volume, [options, ][callback])
212214
POST https://api.luno.com/api/1/marketorder
213215

214216
Example:
@@ -217,7 +219,7 @@ Example:
217219
bitx.postMarketSellOrder(0.01, function(err, order) {});
218220
```
219221

220-
### stopOrder(orderId, callback)
222+
### stopOrder(orderId, [callback])
221223
POST https://api.luno.com/api/1/stoporder
222224

223225
Example:
@@ -226,7 +228,7 @@ Example:
226228
bitx.stopOrder('BXMC2CJ7HNB88U4', function(err, result) {});
227229
```
228230

229-
### getOrder(orderId, callback)
231+
### getOrder(orderId, [callback])
230232
GET https://api.luno.com/api/1/orders/{orderId}
231233

232234
Example:
@@ -235,7 +237,7 @@ Example:
235237
bitx.getOrder('BXHW6PFRRXKFSB4', function(err, result) {});
236238
```
237239

238-
### getTransactions(asset, [options, ]callback)
240+
### getTransactions(asset, [options, ][callback])
239241
GET https://api.luno.com/api/1/transactions
240242

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

255-
### getWithdrawals(callback)
257+
### getWithdrawals([callback])
256258
GET https://api.luno.com/api/1/withdrawals
257259

258260
Example:
@@ -261,7 +263,7 @@ Example:
261263
bitx.getWithdrawals(function(err, withdrawals) {});
262264
```
263265

264-
### getWithdrawal(withdrawalId, callback)
266+
### getWithdrawal(withdrawalId, [callback])
265267
GET https://api.luno.com/api/1/withdrawals/{withdrawalId}
266268

267269
Example:
@@ -270,7 +272,7 @@ Example:
270272
bitx.getWithdrawal('1212', function(err, withdrawal) {});
271273
```
272274

273-
### requestWithdrawal(type, amount, callback)
275+
### requestWithdrawal(type, amount, [callback])
274276
POST https://api.luno.com/api/1/withdrawals
275277

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

282-
### cancelWithdrawal(withdrawalId, callback)
284+
### cancelWithdrawal(withdrawalId, [callback])
283285
DELETE https://api.luno.com/api/1/withdrawals/{withdrawalId}
284286

285287
Example:

0 commit comments

Comments
 (0)