In this Python article iam going to show you Weather Forecast with OpenWeatherMap API, so for this article we are using PyOWM library .
What is PyOWM ?
PyOWM is a client Python wrapper library for OpenWeatherMap web APIs. It allows quick and easy consumption of OWM data from Python applications via a simple object model and in a human-friendly fashion.
What APIs can I access with PyOWM?
With PyOWM you can interact programmatically with the following OpenWeatherMap web APIs:
- Weather API v2.5, offering
- current weather data
- weather forecasts
- weather history
- Agro API v1.0, offering polygon editing, soil data, satellite imagery search and download
- Air Pollution API v3.0, offering data about CO, O3, NO2 and SO2
- UV Index API v3.0, offering data about Ultraviolet exposition
- Stations API v3.0, allowing to create and manage meteostation and publish local weather measurements
- Weather Alerts API v3.0, allowing to set triggers on weather conditions and areas and poll for spawned alerts
And You can also get image tiles for several map layers provided by OWM
The documentation of OWM APIs can be found on the OWM Website
Installation
The easiest way to install is using pip
1 |
pip install pyowm |
So now this is the complete code for Python Weather Forecast with OpenWeatherMap API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import pyowm owm = pyowm.OWM('YOUR API KEY') # You MUST provide a valid API key # Search for current weather in London (Great Britain) observation = owm.weather_at_place('London,GB') w = observation.get_weather() print(w) # Weather details print(w.get_wind()) print(w.get_humidity()) print(w.get_temperature('celsius')) |
So now run the complete code and this will be the result
Also you can watch the complete video for this article
Subscribe and Get Free Video Courses & Articles in your Email
1 thought on “Python Weather Forecast with OpenWeatherMap API”
Comments are closed.