def get_price(symbols, from_sym="BTC", to_sym="USD"): if from_sym not in symbols or to_sym not in symbols: return "Please check your inputs for from and to symbol" r =requestutil.Get(f"https://min-api.cryptocompare.com/data/price?fsym={from_sym}&tsyms={to_sym}") return r
def get_pron_for_word(word): url = f"https://api.pearson.com/v2/dictionaries/entries?headword={word}" data = R.Get(url) list_of_urls = [] f = lambda x: str(x).endswith(".mp3") find_value_in_dict_recursively(data, f, values=list_of_urls) list_of_urls = ["https://api.pearson.com" + u for u in list_of_urls] return list_of_urls
def get_exchangerate_history_from_api(src, target, start_date, end_date): url = f"https://api.exchangeratesapi.io/history?start_at={start_date}&end_at={end_date}&base={src}&symbols={target}" data = R.Get(url) return data
def get_exchangerate_from_api(src, target): url = f"https://api.exchangeratesapi.io/latest?symbols={target}&base={src}" data = R.Get(url) value = data['rates'][target] return value
def load_symbols(): base_url_syml_mapping = f"https://min-api.cryptocompare.com/data/pair/mapping/fsym?fsym=BTC&api_key={API_KEY}" resp = requestutil.Get(base_url_syml_mapping) symbols = ["BTC"] + list(set([ item["tsym"] for item in resp.get("Data")])) return symbols