We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4314727 commit 538db67Copy full SHA for 538db67
api/price_oracle.py
@@ -0,0 +1,17 @@
1
+# api/price_oracle.py
2
+
3
+import requests
4
5
+class PriceOracle:
6
+ def __init__(self):
7
+ self.api_url = "https://api.coingecko.com/api/v3/simple/price"
8
9
+ def get_price(self, coin_id):
10
+ try:
11
+ response = requests.get(f"{self.api_url}?ids={coin_id}&vs_currencies=usd")
12
+ response.raise_for_status()
13
+ data = response.json()
14
+ return data[coin_id]['usd']
15
+ except Exception as e:
16
+ print(f"Error fetching price data: {e}")
17
+ return None
0 commit comments