I just want to share Srib to help with Crypto analysis, hopefully it's useful.
# Import the required libraries
import requests
import json
# Function to get crypto price data from API
def get_crypto_prices(coins):
url=f"https://api.coingecko.com/api/v3/simple/price?ids={coin}&vs_currencies=usd"
response = requests.get(url)
data = response.json()
return data[coin]['usd']
# Function to get forex price data from API (eg for EUR/USD)
def get_forex_price(pair):
url = f"https://api.exchangerate-api.com/v4/latest/{pair}"
response = requests.get(url)
data = response.json()
return data['rates'][pair]
# Example of use:
# Get Bitcoin price in USD
bitcoin_price = get_crypto_prices('bitcoin')
print("Bitcoin Price (USD):", bitcoin_price)
# Get EUR/USD price
eur_usd_price = get_forex_price('EUR-USD')
print("EUR/USD Price:", eur_usd_price)