Skip to content
Permalink
68adcc6bda
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
41 lines (35 sloc) 1.44 KB
import requests
import json
class Currency:
def __init__(self):
self.currencyName = None
self.url = "https://coinranking1.p.rapidapi.com/reference-currencies"
self.headers = {
"X-RapidAPI-Key": "eeb1cf1684msh83985ef0f081d92p1754ddjsn6941f32fe3d1",
"X-RapidAPI-Host": "coinranking1.p.rapidapi.com"
}
self.querystring = {"limit": "10", "offset": "0"}
def apiAllCurrency(self):
# we're getting all the coins
val = requests.get(self.url, headers=self.headers, params=self.querystring)
data = json.loads(val.text)
return data
def getAllCurrency(self):
data = self.apiAllCurrency()
print("\n data", data)
print("Total Currencies: ", data["data"]["stats"]["total"])
for coin in data["data"]["currencies"]:
print("-----------------------------------------------------------------------------------------\n")
print("\033[1;3mUUID:\033[0m ", coin["uuid"])
print("\033[1;3mtype:\033[0m ", coin["type"])
print("\033[1;3mSymbol:\033[0m ", coin["symbol"])
print("\033[1;3mName:\033[0m ", coin["name"])
print("\033[1;3mSign:\033[0m ", coin["sign"])
print("\033[1;3mImage Link:\033[0m ", coin["iconUrl"])
def setCurrency(self, currencyName):
data = self.apiAllCoin()
print("set all currency all currency")
# coinId
for currency in data["data"]["coins"]:
if currency["symbol"].lower() == currencyName:
self.currencyName = currency["uuid"]