Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
tiaanduplessis committed Jan 30, 2018
2 parents 201ba2f + c39f712 commit 56e324c
Show file tree
Hide file tree
Showing 2 changed files with 9 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
12 changes: 7 additions & 5 deletions index.js
Expand Up @@ -3,7 +3,7 @@
const fetch = require('node-fetch')
const qs = require('qs')

const BASE_URL = 'https://api.coinmarketcap.com/'
const BASE_URL = 'https://api.coinmarketcap.com'

class CoinMarketCap {
constructor ({ version = 'v1' } = {}) {
Expand All @@ -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() : ''}`,
url: `${this.url}/ticker${currency ? `/${currency}/`.toLowerCase() : ''}`,
headers: this.headers,
query: { convert, limit }
query: { start, convert, limit }
})
}

Expand Down

0 comments on commit 56e324c

Please sign in to comment.