meteoalarmapi
An unofficial Python wrapper for MeteoAlarm.org (European weather alerts), which can be used to check whether a given province in your country currently has a weather alert.
This is a maintained fork of meteoalertapi by Rolf Berkenbosch, which has had no releases since February 2024. It keeps the same Meteoalert class and alert fields. See What changed from meteoalertapi.
Installation
pip install meteoalarmapi
Code example
from meteoalarmapi import Meteoalert
# Find your country and province on https://meteoalarm.org/ or https://feeds.meteoalarm.org/
# The province is the area's whole name as the feed gives it (ignoring case), or
# its EMMA_ID code. Part of a name doesn't match: 'Savoie' isn't 'Haute Savoie'.
meteo = Meteoalert('united-kingdom', 'Highlands & Eilean Siar')
# The most severe current alert, or {} when there is none
print(meteo.get_alert())
# Every alert for the province, most severe first
for alert in meteo.get_alerts():
print(alert['event'], alert['severity'], alert['onset'], alert['expires'])
# Whole area names in the feed containing some text, such as
# ['Coast and fjords in Rogaland'] for 'Rogaland'. The feed only lists areas
# that have a warning now, so an empty list doesn't mean a name is wrong.
print(Meteoalert('norway', 'Rogaland').suggest_areas())
# Also match the areas whose names contain the province, as before 0.7.0.
# After get_alerts(), partial_areas lists those areas, and province_matched
# says whether the province matched as a whole name or code.
meteo = Meteoalert('norway', 'Rogaland', partial=True)
print(meteo.get_alerts(), meteo.province_matched, meteo.partial_areas)
Some countries, such as Norway, don't name provinces in their feed and only give each alert's area as a polygon. For those, give a latitude and longitude instead. You get the alerts whose area contains that point:
meteo = Meteoalert('norway', latitude=60.392, longitude=5.324) # Bergen
print(meteo.get_alerts())
This works for any feed that includes polygons, including the UK's. With both a province and a point, you get alerts matching either.
Most other feeds, such as Spain's and Germany's, give each area only as an EMMA_ID code. Some, such as France's and Belgium's, give a NUTS or FIPS code instead, but every entry's link still names its EMMA_ID, so they work the same way. To match those by point too, look up the point's EMMA_ID area once with update_geocodes(), store what it returns, and pass it in:
from meteoalarmapi import update_geocodes
geocodes = update_geocodes(37.626, -0.997) # Cartagena: downloads MeteoAlarm's area outlines once
meteo = Meteoalert('spain', latitude=37.626, longitude=-0.997, geocodes=geocodes)
print(meteo.get_alerts())
# later, e.g. once a day: only checks for a newer file, and downloads it if there is one
geocodes = update_geocodes(37.626, -0.997, geocodes, outdated=meteo.geocodes_outdated)
The area outlines are MeteoAlarm's geocodes file (33 MB), which update_geocodes() downloads from MeteoAlarm's Redistribution Hub and doesn't keep. What it returns is small and JSON-safe: the point's codes, the other codes in its country, and the file version. Later calls read MeteoAlarm's file listing (a few KB) once a month, or once a day when geocodes_outdated says the feed had a code it didn't know, and download again only when there's a newer file. get_alerts() itself never downloads it.
Each alert also has the CAP message fields identifier, message_type (Alert, Update or Cancel), references and sent, so you can follow a warning across updates and tell when one is cancelled.
Some feeds keep warnings for a while after they end. Pass include_expired=False to leave expired alerts out. Future alerts, which haven't started yet, are kept:
for alert in meteo.get_alerts(include_expired=False):
print(alert['event'], alert['onset'], alert['expires'])
Alerts are ranked with current ones first, then by awareness level (awareness_level, e.g. 3; Orange; Severe), then by CAP severity. Alerts that rank equally keep their order in the feed.
asyncio
AsyncMeteoalert is the same client for asyncio, on aiohttp. Install it with the async extra:
pip install "meteoalarmapi[async]"
It takes the same arguments as Meteoalert, plus an aiohttp.ClientSession that you own (it's never closed for you), and returns the same alerts, in the same order, with the same exceptions:
import aiohttp
from meteoalarmapi import AsyncMeteoalert, async_update_geocodes
async with aiohttp.ClientSession() as session:
meteo = AsyncMeteoalert('norway', latitude=60.392, longitude=5.324, session=session)
alert = await meteo.async_get_alert()
alerts = await meteo.async_get_alerts(include_expired=False)
# update_geocodes(), with the session first
geocodes = await async_update_geocodes(session, 37.626, -0.997)
The alerts' CAP documents are fetched concurrently, and reading the geocodes file runs in the event loop's default executor so it doesn't block the loop. In Home Assistant, pass async_get_clientsession(hass) as the session. The sync Meteoalert stays, unchanged, and doesn't need aiohttp.
What changed from meteoalertapi
- The package is now imported as
meteoalarmapiinstead ofmeteoalertapi. get_alert()returns the most severe current alert. Before, it returned the first match in the feed, so a yellow warning could hide an amber one.- New
get_alerts()returns every matching alert, most severe first. get_alerts(include_expired=False)leaves out expired alerts, which some feeds keep for a while. Future alerts are kept.- Alerts can be matched by a latitude and longitude inside the alert's area, for feeds without provinces (meteoalert-api#35) (0.5.0).
- Points also match areas given only as EMMA_ID codes, using MeteoAlarm's geocodes file downloaded once by
update_geocodes()(0.5.0). - An asyncio client,
AsyncMeteoalert, on aiohttp with a session you pass in (pip install "meteoalarmapi[async]") (0.6.0). - A province name must match a whole area name in the feed, not just part of one, so 'Porto' no longer gets the alerts for 'Porto Santo' (meteoalert-api#31). Names with brackets, such as 'Graz (Stadt)', now match. Before, the name was used as a regular expression.
suggest_areas()lists the whole names in the feed that contain a partial one (0.7.0).partial=Truebrings back matching part of a name, when asked for (0.9.0). - Points and EMMA_ID codes also match feeds that give areas as NUTS or FIPS codes, such as France's, Belgium's and Romania's, using the EMMA_ID in each entry's link (0.8.0).
awareness_level,awareness_typeand the other CAP parameters are now included for feeds with a single language, such as the UK's. Before, they were silently dropped.- An alert listed several times in the feed (once per language or area) is returned and fetched only once.
- Each alert includes the CAP
identifier,message_type,referencesandsent. - Python 3.10 or newer is required.
Changelog
See the CHANGELOG file.
License
MIT. Original work copyright (c) 2018 Rolf Berkenbosch.
Metadata
Release files for meteoalarmapi 0.9.0
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 |
|---|---|---|---|---|
| meteoalarmapi-0.9.0.tar.gz | 71.9 kB | With provenance | Details for meteoalarmapi-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| meteoalarmapi-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for meteoalarmapi-0.9.0-py3-none-any.whl |
Total release size: 86.9 kB
Release files / meteoalarmapi-0.9.0.tar.gz
| Download URL | meteoalarmapi-0.9.0.tar.gz |
|---|---|
| Size | 71.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7eba43f1f2d2a93ed0f30ac3dea64cf045dd00e20ba83e78adafead9eeddca9a
|
|
BLAKE2b-256 checksum How to use checksums |
94d18067ed88e48e7a7fc2b69b35ccc25ae022734cb0aff8f41886b27395cc77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / meteoalarmapi-0.9.0-py3-none-any.whl
| Download URL | meteoalarmapi-0.9.0-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b18155f5f54408663faf07fa17e9669ef765e9fa1d9088b082bc71bf0fdab31
|
|
BLAKE2b-256 checksum How to use checksums |
513a1db5801c95e18d3c6daeff24afaf00a113afa734c125fa56df7176094616
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for meteoalarmapi 0.9.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for meteoalarmapi-0.9.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA 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.