OpenweatherPy
Table of contents
About
This project retrieves the weather data from openweathermap.org in JSON format. It also provides data in different languages and in different units like Fahrenheit, Celsius and Kelvin.
Requirements
Ensure that you have an openweathermap.org Api key. If not, then click here to create one.
python>=3.0
Dependencies
requests
Installation
$ pip install openweatherpy
Usage
>>> from OpenweatherPy import Weather
>>> weather = WeatherPy('API_KEY')
Get report of a city or a country
>>> city = weather.query(city='City Name') #Get weather report of a city
>>> country = weather.query(country='Country Code') #Get weather report of a country
>>> location = weather.query(city='City Name', country='Country Code') #City and Country keywords and can be used at a same time
Get weather and it's description
>>> mumbai = weather.query(city='mumbai')
>>> mumbai.weather
>>> mumbai.description
Output:
Clouds
broken clouds
Get temperature, pressure, humidity, max temperature, min temperature
>>> mumbai.temperature
>>> mumbai.pressure
>>> mumbai.humidity
>>> mumbai.temp_max
>>> mumbai.temp_min
Output:
289.57
1018.0
72.0
290.37
288.71
Get co-ordinates
>>> mumbai.co_ordinates
Output:
{'lon': 72.85, 'lat': 19.01}
Get cloudiness, sunrise time, sunset time and timezone
>>> mumbai.clouds
>>> mumbai.sunrise
>>> mumbai.sunset
>>> mumbai.timezone
Output:
{'all': 75}
1599872150
1599916449
19800
Note: The sunrise, sunset and timezone are as per UTC time.
Get wind details
>>> mumbai.wind
Output:
{'speed': 4.1, 'deg': 150, 'gust': 9.3}
Get city Id
>>> mumbai.id
Output:
1275339
Get average visibility meter
>>> mumbai.visibility
Output:
2500
Get weather report of location by Id
>>> manhattan = weather.getbyid(5125771)
Get weather report of a location by geographical co-ordinates i.e latitude and longitude
>>> delhi = weather.getbycoords(lat=28.67, lon=77.22)
Get weather report in different language
The default language is english (en).
>>> weather = WeatherPy('API_KEY', lang='hi')
Get weather report in different unit
The default unit is Kelvin and optional are celsius and fahrenheit.
>>> weather = WeatherPy('API_KEY', unit='Fahrenheit', lang='hi')
Get all language codes
>>> weather.languages()
Output:
{
'af': 'Afrikaans',
'al': 'Albanian',
'ar': 'Arabic',
'az': 'Azerbaijani',
'bg': 'Bulgarian',
'ca': 'Catalan',
'cz': 'Czech',
'da': 'Danish',
'de': 'German',
'el': 'Greek',
'en': 'English',
'eu': 'Basque',
'fa': 'Persian(Farsi)',
'fi': 'Finnish',
'fr': 'French',
'gl': 'Galician',
'he': 'Hebrew',
'hi': 'Hindi',
'hr': 'Croatian',
'hu': 'Hungarian',
'id': 'Indonesian',
'it': 'Italian',
'ja': 'Japanese',
'kr': 'Korean',
'la': 'Latvian',
'lt': 'Lithuanian',
'mk': 'Macedonian',
'no': 'Norwegian',
'nl': 'Dutch',
'pl': 'Polish',
'pt': 'Portuguese',
'pt_br': 'Português Brasil',
'ro': 'Romanian',
'ru': 'Russian',
'sv, se': 'Swedish',
'sl': 'Slovenian',
'sp, es': 'Spanish',
'sr': 'Serbian',
'th': 'Thai',
'tr': 'Turkish',
'ua, uk': 'Ukranian',
'vi': 'Vietnamese',
'zu': 'Zulu',
}
License
openweatherpy is distributed under the terms of MIT License .
Metadata
Release files for openweatherpy 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openweatherpy-0.0.7.tar.gz | 5.7 kB | Without provenance | Details for openweatherpy-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openweatherpy-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for openweatherpy-0.0.7-py3-none-any.whl |
Total release size: 11.2 kB
Release files / openweatherpy-0.0.7.tar.gz
| Download URL | openweatherpy-0.0.7.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2384629b2650800f7f4f73c1b81cfca735880dc19bf1f564eb88fb19aac89eea
|
|
BLAKE2b-256 checksum How to use checksums |
f918f971435c8379f6cd655ae22359d531400bc779de0cec4fe9dd60e86880c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Release files / openweatherpy-0.0.7-py3-none-any.whl
| Download URL | openweatherpy-0.0.7-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fe692a85d59550c7f9dcea3ce66b064bbfff450b6dd66bf5be302d466e1c4aa
|
|
BLAKE2b-256 checksum How to use checksums |
bf64d451080e59f7901440870a079bb04078785ddcaf1a69da70e11ba522aab0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Security for openweatherpy 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.