You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
609 B
25 lines
609 B
7 years ago
|
const fs = require('fs');
|
||
|
const fetch = require('isomorphic-fetch');
|
||
|
const sortby = require('lodash.sortby');
|
||
|
|
||
|
const endpoint = 'https://www.cryptocompare.com/api/data/coinlist/';
|
||
|
|
||
|
/**
|
||
|
* Build the JSON file based on the cryptocompare coinlist.
|
||
|
*/
|
||
|
fetch(endpoint)
|
||
|
.then(response => response.json())
|
||
|
.then(json => {
|
||
|
const sorted = sortby(json.Data, o => o.CoinName);
|
||
|
|
||
|
const symbols = {};
|
||
|
|
||
|
sorted.forEach(currency => {
|
||
|
const {Name, CoinName} = currency;
|
||
|
symbols[Name] = CoinName;
|
||
|
});
|
||
|
|
||
|
fs.writeFileSync('cryptocurrencies.json', JSON.stringify(symbols, null, 2));
|
||
|
console.log('JSON File written');
|
||
|
});
|