Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,34 @@ Example:
bitx.getOrder('BXHW6PFRRXKFSB4', function(err, result) {});
```

### getTransactions(asset, [options, ]callback)
GET https://api.mybitx.com/api/1/transactions
### getTransactions(accountId, [options, ]callback)
GET https://api.mybitx.com/api/1/accounts/{accountId}/transactions

You can find your accountId by calling the Balances API.

Default options:
```javascript
{
offset: 0,
limit: 10
min_row: 1,
max_row: 100
}
```

Example:

```javascript
bitx.getTransactions('XBT', {offset: 5, limit: 20}, function(err, transactions) {});
bitx.getTransactions('319232323', {min_row: 5, max_row: 20}, function(err, transactions) {});
```

### getPendingTransactions(accountId, callback)
GET https://api.mybitx.com/api/1/accounts/{accountId}/pending

You can find your accountId by calling the Balances API.

Example:

```javascript
bitx.getPendingTransactions('319232323', function(err, pendingTransactions) {});
```

### getWithdrawals(callback)
Expand Down
13 changes: 8 additions & 5 deletions lib/BitX.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,20 @@ BitX.prototype.createFundingAddress = function (asset, callback) {
this._request('POST', 'funding_address', {asset: asset}, callback)
}

BitX.prototype.getTransactions = function (asset, options, callback) {
BitX.prototype.getTransactions = function (accountId, options, callback) {
if (typeof options === 'function') {
callback = options
options = null
}
var defaults = {
asset: asset,
offset: 0,
limit: 10
min_row: 1,
max_row: 100
}
this._request('GET', 'transactions', extend(defaults, options), callback)
this._request('GET', 'accounts/' + accountId + '/transactions', extend(defaults, options), callback)
}

BitX.prototype.getPendingTransactions = function (accountId, callback) {
this._request('GET', 'accounts/' + accountId + '/pending', null, callback)
}

BitX.prototype.getWithdrawals = function (callback) {
Expand Down
12 changes: 6 additions & 6 deletions test/IntegrationTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ tap.test('getTransactions should return the transactions', function (t) {

server.on('request', function (req, res) {
t.equal(req.method, 'GET')
t.equal(req.url, '/api/1/transactions?asset=XBT&offset=0&limit=10')
t.equal(req.url, '/api/1/accounts/1224342323/transactions?min_row=1&max_row=100')
res.end(JSON.stringify(expectedTransactions))
})

bitx.getTransactions('XBT', function (err, transactions) {
bitx.getTransactions('1224342323', function (err, transactions) {
t.ifErr(err)
t.deepEqual(transactions, expectedTransactions)
t.end()
Expand Down Expand Up @@ -625,15 +625,15 @@ tap.test('getTransactions should send options and return the transactions', func

server.on('request', function (req, res) {
t.equal(req.method, 'GET')
t.equal(req.url, '/api/1/transactions?asset=XBT&offset=5&limit=5')
t.equal(req.url, '/api/1/accounts/1224342323/transactions?min_row=1&max_row=3')
res.end(JSON.stringify(expectedTransactions))
})

var options = {
offset: 5,
limit: 5
min_row: 1,
max_row: 3
}
bitx.getTransactions('XBT', options, function (err, transactions) {
bitx.getTransactions('1224342323', options, function (err, transactions) {
t.ifErr(err)
t.deepEqual(transactions, expectedTransactions)
t.end()
Expand Down