簡體   English   中英

如何從 coinmarketcap API 請求特定硬幣列表? 試圖訪問一個排名超過 5000 的

[英]How to request list of specific coins from coinmarketcap API? Trying to access one ranked over 5000

現在我設置它的方式從 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']```

如果您只想訪問預定義的硬幣列表,請使用報價/最新而不是列表/最新(為您提供所有硬幣),請使用“v1/cryptocurrency/quotes/latest”(檢查https://coinmarketcap.com /api/documentation/v1/#operation/getV1CryptocurrencyQuotesLatest )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM