Skip to content

Commit

Permalink
Merge pull request #101 from DigitalFeonix/master
Browse files Browse the repository at this point in the history
Change API endpoint to get just config currencies
  • Loading branch information
matteodanelli authored Dec 2, 2021
2 parents 90e2a9f + 1be163b commit f3f1bcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
20 changes: 7 additions & 13 deletions MMM-cryptocurrency.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Module.register('MMM-cryptocurrency', {
maximumFractionDigits: 5,
coloredLogos: true,
fontSize: 'xx-large',
limit: '100',
apiDelay: 300000,
},

Expand Down Expand Up @@ -144,7 +143,8 @@ Module.register('MMM-cryptocurrency', {

getTicker: function() {
var conversion = this.config.conversion;
var url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit=' + this.config.limit + '&convert=' + conversion + '&CMC_PRO_API_KEY=' + this.config.apikey;
var slugs = this.config.currency.join(',');
var url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?slug=' + slugs + '&convert=' + conversion + '&CMC_PRO_API_KEY=' + this.config.apikey;
this.sendSocketNotification('get_ticker', url);
},

Expand Down Expand Up @@ -247,17 +247,11 @@ Module.register('MMM-cryptocurrency', {
*/
getWantedCurrencies: function(chosenCurrencies, apiResult) {
var filteredCurrencies = []
for (var i = 0; i < chosenCurrencies.length; i++) {
for (var j = 0; j < apiResult.data.length; j++) {
var userCurrency = chosenCurrencies[i]

var remoteCurrency = apiResult['data'][j]
if (userCurrency == remoteCurrency.slug) {
remoteCurrency = this.formatPrice(remoteCurrency)
remoteCurrency = this.formatPercentage(remoteCurrency)
filteredCurrencies.push(remoteCurrency)
}
}
for (var symbol in apiResult.data) {
var remoteCurrency = apiResult.data[symbol]
remoteCurrency = this.formatPrice(remoteCurrency)
remoteCurrency = this.formatPercentage(remoteCurrency)
filteredCurrencies.push(remoteCurrency)
}
return filteredCurrencies
},
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ A <a href="https://github.com/MichMich/MagicMirror">MagicMirror</a> module used
|`showGraphs`| Possibility to show currency graph over the last week in `displayType: logo`. <br> **Type:** `boolean` <br> **Default** <i>false</i> |
|`coloredLogos`| Toggles white or colored logos `displayType: logo`. <br> **Type:** `boolean` <br> **Default** <i>true</i> |
|`fontSize`| Dimension of price text. You can specify pixel values, em values or keywords.<br> **Type:** `string` <br>**Options:** `xx-small`, `x-small`, `small`, `medium`, `large`, `x-large`, `xx-large` <br> **Default** <i>xx-large</i> |
|`limit`| Number of currencies to download, according to CoinMarketCap ranking. Increase this value only if you cannot display a currency. <br> **Type:** `string` <br> **Default** <i>100</i> |

Here is an example of an entry in `config.js`
```
Expand Down

0 comments on commit f3f1bcc

Please sign in to comment.