top of page
Search
  • Writer's pictureSenthil Pitchappan V

Weather API in 6 Lines of Code | Python

To Get API Key:

Open Weather API software that works in all environments, optimized for your location. To see all the countries supported Click Here.


Code:

import requests
api_address='http://api.openweathermap.org/data/2.5/weather?appid=YOUR_API_KEY&q='
city = input('City Name :')
url = api_address + city
json_data = requests.get(url).json()
print(json_data)

#formatted_data = json_data['weather'][0]['main']
#print(formatted_data)

Changes you should make:

  1. YOUR_API_KEY.

  2. Change formatted data code according to your needy.


Further Process:

  1. Create Webapp using Flask or Django.



Output JSON Format:




55 views0 comments

Recent Posts

See All

Σχόλια


bottom of page