Get the weather of any city instantly in your project
Project description
easyOpenWeather module
This module is used to get or print the weather deatils using open weather API easily
install module using pip command
pip install easyOpenWeather
external dependencies required -
- requests
pip install requests
- tabulate
pip install tabulate
To import in project -
from easyOpenWeather import module
Then make a object instance of WeatherDataClass
obj = module.WeatherDataClass()
Now you need to at least set the city name and api key first
obj.setCityName("london")
obj.setApiKey("fe82651e607e4******ba45e39aa7e17")
To know how to get your own api key from open weather click here
Now you need to pass a list containing attributes for which you need weather data
List Attributes -
- temp -> for temperature in kelvin
- tempInC -> for temperature in celcius
- tempInF -> for temperature in f
- tempMin -> for min temp - unit is decided from above
- tempMax -> for max temp - unit is decided from above
- pressure -> for pressure
- humidity -> for humidity
- wind speed -> for wind speed
- wind direction -> for wind direction
- description -> for description - like clear sky etc
Note - use only one at a time from temp , tempInC , tempInF
All output data is in SI units
To set list Use -
listPass = ["tempInC" , "tempMin" , "tempMax" , "pressure" , "humidity" , "windSpeed" , "windDirection" , "clouds" , "description"]
obj.setList(listPass)
To get data in dictionary format -
obj.getInfo()
The function will return a dictionary.
Sample dictionary that you will get for listPass = ["tempInC" , "tempMin" , "tempMax" , "pressure" , "humidity" , "windSpeed" , "windDirection" , "clouds" , "description"] :
{'tempInC': 11.01, 'tempMin': 10.71, 'tempMax': 11.82, 'pressure': 998, 'humidity': 53, 'windSpeed': 8.7, 'windDirection': 260, 'clouds': 9, 'description': 'clear sky'}
This module also include a inbuilt function to directly print the data in a tabular format
obj.printData()
Other methods -
-
obj.setStringKey(stringKey) - To set custom api url. Default url - https://api.openweathermap.org/data/2.5/weather?q=
Some getters -
-
obj.getStringKey()
-
obj.getApiKey()
-
obj.getCityName()
Sample program -
from easyOpenWeather import module
obj = module.WeatherDataClass()
obj.setCityName("london")
obj.setApiKey("fe82651e607e46db61dba45e39aa7e17")
listPass = ["tempInC" , "tempMin" , "tempMax" , "pressure" , "humidity" , "windSpeed" , "windDirection" , "clouds" , "description"]
obj.setList(listPass)
obj.printData()
Contibute -
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for easyOpenWeather-0.22-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6da1f49d3eed213b7d43ae9a4a1acbdc387fe924c7dc0c1088469dc1001ddaf9 |
|
MD5 | 7cd1ade5c0757154f8947c2769c89b73 |
|
BLAKE2b-256 | b8024d5a46fc17fcb8e244e3569ef0d566ff9e94d091b87480711aaeafc42654 |