1

现在我设置它的方式从 1 到 5000 拉,但我不知道如何访问排名超过 5000 的硬币。我正在尝试拉 GBTC 的价格

    'X-CMC_PRO_API_KEY' : KEY,
    'Accepts': 'application/json'
}

params = {
    'start':'1',
    'limit' : '5000',
    'convert' : 'USD'
}

url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'
json = requests.get(url, params=params, headers=headers).json()
coins = json['data']

current_price = {}
for coin in coins:
    if coin['symbol'] == 'BTC' or coin['symbol'] == 'ETH' or coin['symbol'] == 'GBTC':
        current_price[coin['symbol']] = coin['quote']['USD']['price']```
4

1 回答 1

0

如果您只想访问预定义的硬币列表,请使用报价/最新而不是列表/最新(为您提供所有硬币),请使用“v1/cryptocurrency/quotes/latest”(查看https://coinmarketcap.com /api/documentation/v1/#operation/getV1CryptocurrencyQuotesLatest )

于 2022-01-25T15:37:20.583 回答