Skip to content

Commit

Permalink
Merge pull request #6 from abhinavk99/ticker-start-option
Browse files Browse the repository at this point in the history
Added start option for getTicker method
  • Loading branch information
tiaanduplessis committed Jan 30, 2018
2 parents 3d2c248 + bad2a47 commit 192f042
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -88,6 +88,7 @@ Get ticker information
**Parameters**

- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Options for the request:
- `options.start` **Int?** Return results from rank start and above
- `options.limit` **Int?** Only returns the top limit results
- `options.convert` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Return price, 24h volume, and market cap in terms of another currency
- `options.currency` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Return only specific currency
Expand All @@ -99,6 +100,7 @@ const client = new CoinMarketCap()
client.getTicker({limit: 3}).then(console.log).catch(console.error)
client.getTicker({limit: 1, currency: 'bitcoin'}).then(console.log).catch(console.error)
client.getTicker({convert: 'EUR'}).then(console.log).catch(console.error)
client.getTicker({start: 0, limit: 5}).then(console.log).catch(console.error)
```

### getGlobal
Expand Down
8 changes: 5 additions & 3 deletions index.js
Expand Up @@ -18,7 +18,8 @@ class CoinMarketCap {
* Get ticker information
*
* @param {Object=} options Options for the request:
* @param {Int=} options.limit Only returns the top limit results
* @param {Int=} options.start Return results from rank start + 1 and above
* @param {Int=} options.limit Only returns limit number of results
* @param {String=} options.convert Return price, 24h volume, and market cap in terms of another currency
* @param {String=} options.currency Return only specific currency
*
Expand All @@ -27,12 +28,13 @@ class CoinMarketCap {
* client.getTicker({limit: 3}).then(console.log).catch(console.error)
* client.getTicker({limit: 1, currency: 'bitcoin'}).then(console.log).catch(console.error)
* client.getTicker({convert: 'EUR'}).then(console.log).catch(console.error)
* client.getTicker({start: 0, limit: 5}).then(console.log).catch(console.error)
*/
getTicker ({ limit, convert, currency }) {
getTicker ({ start, limit, convert, currency }) {
return createRequest({
url: `${this.url}/ticker${currency ? `/${currency}`.toLowerCase() : ''}`,
headers: this.headers,
query: { convert, limit }
query: { start, convert, limit }
})
}

Expand Down
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -28,8 +28,6 @@
"devDependencies": {
"husky": "^0.14.3",
"jest": "^22.0.0",
"prettier-standard": "^8.0.0"
"jest": "^22.0.0",
"prettier-standard": "^7.0.1"
},
"dependencies": {
Expand Down

0 comments on commit 192f042

Please sign in to comment.