2 回答

TA貢獻1780條經驗 獲得超5個贊
因為 coinmarketcap.com 上的 v1 API 現在已棄用、關閉,并在每個請求上返回。{'statusCode': 404, 'error': 'Not Found', 'message': 'Not Found'}

TA貢獻1111條經驗 獲得超0個贊
此 API 如上所述進行折舊,運行以下代碼,返回的字典聲明相同的內容。
{'statusCode': 410, 'error': 'Gone', 'message': 'WARNING: This API is now offline. Please switch to the new CoinMarketCap API. (https://pro.coinmarketcap.com/migrate/)'}
import requests
import json
TICKER_API_URL = 'https://api.coinmarketcap.com/v1/ticker/'
def get_latest_crypto_price(crypto):
response = requests.get(TICKER_API_URL+crypto)
response_json = response.json()
return response_json
price = get_latest_crypto_price('bitcoin')
print(price)
添加回答
舉報