@icgio/icg-utils 1.7.9 → 1.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/coingecko-coins-map.js +1570 -1694
- package/lib/coingecko.js +12 -12
- package/package.json +1 -1
package/lib/coingecko.js
CHANGED
|
@@ -98,7 +98,7 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
|
|
|
98
98
|
let get_coingecko_rate = (page, cb) => {
|
|
99
99
|
let url = 'https://api.coingecko.com/api/v3/coins/markets?vs_currency=' + quote_cur.toLowerCase() + '&per_page=' + per_page_nums + '&page=' + page
|
|
100
100
|
needle.get(url, options, (err, res, body) => {
|
|
101
|
-
console.log('fetching coingecko rate: body length', _.get(body, 'length'))
|
|
101
|
+
console.log('fetching coingecko rate: body length', _.get(body, 'length', body))
|
|
102
102
|
if (body && body.length > 0) {
|
|
103
103
|
for (let coin of body) {
|
|
104
104
|
let symbol = coin.symbol
|
|
@@ -165,19 +165,19 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
|
|
|
165
165
|
|
|
166
166
|
// https://api.coingecko.com/api/v3/coins/list
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
needle.get('https://api.coingecko.com/api/v3/coins/list', (err, res, body) => {
|
|
169
|
+
let list = body
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
let map = {}
|
|
172
|
+
for (let line of list) {
|
|
173
|
+
let cur = line.symbol.toUpperCase()
|
|
174
|
+
_.set(map, [cur], line.id)
|
|
175
|
+
}
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
map['ETH'] = 'ethereum'
|
|
178
|
+
map['MTR'] = 'meter-stable'
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
console.log(JSON.stringify(map, null, 4))
|
|
181
|
+
})
|
|
182
182
|
|
|
183
183
|
module.exports = get_coingecko_rates
|