diff --git a/Python/050_apidata.py b/Python/050_apidata.py new file mode 100644 index 0000000..313a03e --- /dev/null +++ b/Python/050_apidata.py @@ -0,0 +1,20 @@ +# Retrieving data from a Web/REST API + +# Import the library for web requests +import requests + +# The URL of our API call +URL = "https://jackpot.jaj.com/weather/" + +# Make the request for data +response = requests.get(URL) + +# response.json() will contain the json data returned from the request. +# This data can be accessed just like a dictionary/dict. +# Load the URL above in Firefox or Edge to see the available data fields +print("Current Weather in Beavercreek, OH") +print(f" Conditions: {response.json()['current']['weather'][0]['main']}") +print(f" Temperature: {response.json()['current']['temp']}° F (feels like {response.json()['current']['feels_like']}° F)") +print(f" Humidity: {response.json()['current']['humidity']}%") +print(f" Wind: {response.json()['current']['wind_speed']} MPH") +print(f" Prediction: {response.json()['daily'][0]['summary']}") \ No newline at end of file