Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Added functionality to fetch order books for all markets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabbath committed Feb 11, 2017
1 parent 41a98f0 commit 1dc32e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Example response:

### returnOrderBook(currencyA, currencyB, callback)

Returns the order book for a given market.
Returns the order book for a given market. If currency A is specified as 'all' and currency B is not specified, then order books for all markets will be returned.
Calls API method `returnOrderBook`.

poloniex.returnOrderBook('VTC', 'BTC', function(err, data) {
Expand Down
15 changes: 12 additions & 3 deletions lib/poloniex.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,18 @@ module.exports = (function() {
},

returnOrderBook: function(currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
if(currencyA === 'all' && typeof currencyB === 'function'){
//If the user specifies fetching all order books
callback = currencyB;
var parameters = {
currencyPair: 'all'
}
}
else{
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
}

return this._public('returnOrderBook', parameters, callback);
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "poloniex.js",
"version": "0.0.7",
"version": "0.0.8",
"description": "Poloniex API client",
"author": "Premasagar Rose <[email protected]>",
"license": "MIT",
Expand Down

0 comments on commit 1dc32e2

Please sign in to comment.