如果我使用以下命令请求获取coingecko硬币的完整列表
https://api.coingecko.com/api/v3/coins/list并获取获取'id'条目的每个硬币的ids。
然后,我就可以使用
https://api.coingecko.com/api/v3/simple/price?ids=<coin>&vs_currencies=usd(其中<coin>应替换为来自完整列表的id )(例如,https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd以获得比特币价格),然后按市值重新排序。
这是可行的,但问题是有许多请求,这需要很长时间(至少几个小时)。
是否有可能立即获得前300枚硬币的id按市值计算?
发布于 2020-07-26 16:27:56
有Coingecco API请求markets,返回硬币价格,市值和市值排名等信息。您可以按市值排名对其进行排序,只需获取JSON数组的前300个元素。
https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc响应看起来像这样:
[
{
"id": "bitcoin",
"symbol": "btc",
"name": "Bitcoin",
"image": "https://assets.coingecko.com/coins/images/1/large/bitcoin.png?1547033579",
"current_price": 9664.88,
"market_cap": 178353923560,
"market_cap_rank": 1,
...
"last_updated": "2020-07-26T05:05:03.478Z"
},
{
"id": "ethereum",
"symbol": "eth",
"name": "Ethereum",
"image": "https://assets.coingecko.com/coins/images/279/large/ethereum.png?1595348880",
"current_price": 302.53,
"market_cap": 33895800150,
"market_cap_rank": 2,
...
},更新:要获得准确的300个结果,请使用以下请求:
https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=3https://stackoverflow.com/questions/63075151
复制相似问题