Permalink
Cannot retrieve contributors at this time
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?
WeatherBot/API2.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (19 sloc)
1.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def citycall(city): | |
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 | |
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 | |
print(data) | |
print(data['weather']) | |
print(data['weather'][0]['description']) # Displays incoming data | |
print(data['wind']['speed']) | |
def countrycall(country): | |
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 | |
call = {'APPID': api_key, 'q': country} # Takes the three 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 | |
x = input("") | |
citycall(x) | |