I have written the following code-
from boltiot import Bolt
api_key = “d231b44f-9474-4879-bc4f-9a95463a42ba”
device_id = “BOLT294186”
mybolt = Bolt(api_key, device_id)
def get_bitcoin_price():
URL = “https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,INR” # REPLACE WITH CORRECT URL
response = requests.request(“GET”, URL)
response = json.loads(response.text)
current_price = response[“USD”]
return current_price
selling_price=7400
while True:
#Step 1- Fetch price from API
price_fetched=get_bitcoin_price()
print(“The current price is”,price_fetched)
print(“Your selling Price is”,selling_price)
#Step 2- Comaparing with selling price
if price_fetched > selling_price:
print(“The current price is greater than the selling price”)
buzzer=mybolt.digitalWrite(‘0’,HIGH)
print(buzzer)
#Step 3- Time Delay
time_sleep(30)
I am getting following error-
Traceback (most recent call last):
File “code.py”, line 16, in
price_fetched=get_bitcoin_price()
File “code.py”, line 8, in get_bitcoin_price
response = requests.request(“GET”, URL)
NameError: name ‘requests’ is not defined
Please help me to debug this.
Thank you.