-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcripto.py
More file actions
38 lines (27 loc) · 861 Bytes
/
cripto.py
File metadata and controls
38 lines (27 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
def main_crip(cripto:str = "bitcoin", moeda_preco:str = "brl" ) -> str:
'''
cripto exemplos
bitcoin
ethereum
solana
moeda_preco exemplos
Dolar -> usd
Real -> brl
'''
url_crip = "https://api.coingecko.com/api/v3/simple/price"
params = {
"ids": cripto.lower(),
"vs_currencies": moeda_preco.lower(),
"include_24hr_change": "true"
}
response = requests.get(url_crip, params=params)
data = response.json()
simbolo = {
"usd" : "$",
"brl" : "R$",
"eur" : "€"
}
print(f"Cripto: {cripto.upper()}\nValor: {simbolo.get(moeda_preco)}{data[cripto][moeda_preco]}\nTaxa de Variacao(24h): {data[cripto][f"{moeda_preco}_24h_change"]}")
if __name__ == "__main__":
main_crip(cripto="bitcoin", moeda_preco="eur")