Skip to content

Python module for getting several of OpenWeatherMap API at once

License

Notifications You must be signed in to change notification settings

viktak/owm2json

Repository files navigation

GitHub GitHub code size in bytes PyPI PyPI - Python Version PyPI - Format

Discontinuation warning!

As per a recent e-mail from OpenWeatherMap, the API this package calls is being retired:

Dear OpenWeather user,

We would like to inform you about our plans to complete the migration from One Call 2.5 to One Call 3.0 that started 2 years ago. In line with this, access to One Call 2.5 will be finally closed in June 2024. 

The new API (v3.0) requires credit card information to be provided even if you use the free tier: alt text

As I am not willing to give out my card details to anyone just to pay €0, I can not update this component to work with the new API.

If someone is willing to take over the mainenance of this component, I'll be happy to give a hand with the transition.

Otherwise this component will stop working whenever the current API is finally shut down (currently planned for June 2024).

owm2json package

Owm2json is a Python library for combining multiple OpenWeatherMap API calls into one.

Installation

Use the package manager pip to install owm2json.

pip install owm2json

Usage

import owm2json
apinames = ["air_pollution", "roadrisk"]
myOWM = owm2json.owmRequestor(apinames, latitude, longitude, appid)
print(myOWM.GetData())

Explanation

apinames: a list of APIs to call. The full list can be seen on the official OpenWeatherMap web site.
latitude, longitude: coordinates of the desired location.
appid: API key to use with the service. You can obtain yours at OpenWeatherMap

If the call is successful, owm2json returns a string that contains a concatenated version of all the API calls that were requested. It also contains version information about itself.

Sample response from owm2json:

{
    "module": {
        "version": "0.1.86"
    },
    "air_pollution": {
        "coord": {
            "lon": 12.34,
            "lat": 12.34
        },
        "list": [{
            "main": {
                "aqi": 2
            },
            "components": {
                "co": 216.96,
                "no": 0.36,
                "no2": 2.49,
                "o3": 98.71,
                "so2": 5.19,
                "pm2_5": 5.18,
                "pm10": 5.46,
                "nh3": 0.33
            },
            "dt": 1617289200
        }]
    },
    "roadrisk": {
        "message": "Please use POST request according to the documentation https://openweathermap.org/api/road-risk"
    }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

GNU General Public License v3.0

About

Python module for getting several of OpenWeatherMap API at once

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published