diff --git a/README.md b/README.md index 2a7fdbe..dc6016e 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/BitX.js b/lib/BitX.js index bdb5645..e1c1e56 100644 --- a/lib/BitX.js +++ b/lib/BitX.js @@ -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) { diff --git a/test/IntegrationTests.js b/test/IntegrationTests.js index dd96303..9df7845 100644 --- a/test/IntegrationTests.js +++ b/test/IntegrationTests.js @@ -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() @@ -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()