Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jlu5/multiweather
A weather library for Python, supporting multiple backends
https://github.com/jlu5/multiweather
Last synced: about 1 month ago
JSON representation
A weather library for Python, supporting multiple backends
- Host: GitHub
- URL: https://github.com/jlu5/multiweather
- Owner: jlu5
- License: mit
- Created: 2024-09-07T20:36:51.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T19:35:20.000Z (3 months ago)
- Last Synced: 2024-09-16T04:59:55.657Z (3 months ago)
- Language: Python
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# multiweather
A Python weather library supporting multiple backends. Because weather APIs [go](https://www.reddit.com/r/webdev/comments/8tjavu) [away](https://www.reddit.com/r/androidapps/comments/1aoz984/), and you shouldn't have to rewrite your code each time.
## Currently supported
- [Open-Meteo.com](https://open-meteo.com/)
- [OpenWeatherMap](https://openweathermap.org) (Professional collections -> Current weather)
- [PirateWeather](https://pirateweather.net/en/latest/)### Comparison of sources
| Data Source | Open-Meteo | OpenWeatherMap | PirateWeather |
| ---------------------- | ---------------------- | ---------------------------- | --------------- |
| **API Key optional** | ✅ | ❌ | ❌ |
| **Current conditions** | ✅ | ✅ | ✅ |
| **Daily (days)** | ✅ (max 16) | ❌ (paid only) | ✅ (fixed to 7) |
| **Built-in geocoding** | ✅ (city name only) | ✅ (city,country) | ❌ |
| **Output license** | [CC BY 4.0][CC BY 4.0] | [CC BY-SA 4.0][CC BY-SA 4.0] | ❓ |[CC BY 4.0]: https://creativecommons.org/licenses/by/4.0/
[CC BY-SA 4.0]: https://creativecommons.org/licenses/by-sa/4.0/
## Usage
```python
from multiweather import OpenMeteoBackend # or your preferred backendom = OpenMeteoBackend() # pass api_key=... for those backends require one
# Blocking fetcher
weather = om.get_weather_sync((lat, lon))# Or in an async context
async def get_weather():
weather = await om.get_weather((lat, lon))
```Both `get_weather` and `get_weather_sync` return a [`WeatherResponse`](multiweather/data.py) dataclass instance.