Skip to content
Permalink
master
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
# https://www.youtube.com/watch?v=D8-snVfekto
# The First function callweather API is taken from here
import requests
import json
class Weather:
def callWeatherAPI(cityName):
api_key = '' # Our unique key for accessing the api
link = 'https://api.openweathermap.org/data/2.5/weather' # A call which takes the city and outputs data
city = cityName # Lets you input a desired city
call = {'APPID': api_key, 'q': city} # Takes the two parameters required by the API
output = requests.get(link, params=call) # Calls the API with the two things it requested as variables
data = output.json() # stores the incoming data
return(data) # Displays incoming data
def callForecastAPI(lat, lon):
api_key = ''
link = 'https://api.openweathermap.org/data/2.5/onecall'
units = "imperial"
call = {'lat': lat, 'lon': lon, 'APPID': api_key, 'units': units}
output = requests.get(link, params=call)
data = output.json()
return data
#print("hi")
def callForecastAPIdate(lat, lon, date):
api_key = ''
link = 'https://api.openweathermap.org/data/2.5/onecall'
units = "imperial"
call = {'lat': lat, 'lon': lon, 'APPID': api_key, 'dt':date, 'units': units}
output = requests.get(link, params=call)
data = output.json()
print(data)
return data
callForecastAPIdate(35, 139, 1605916800)
#callForecastAPI(35, 139 )
#callWeatherAPI("London")