Posted tagged ‘Meteo Alarm’

Meteoalarm Weather Warnings PHP WebService

January 1, 2018

Accurate, localised weather warnings are a useful addition to any weather website. Historically I have used Wunderground’s Alerts API for this purpose on my own weather website. However, at some point last year Wunderground’s Alerts API stopped returning any weather warnings for the UK even during major weather events. At the time of writing this is still the case.

I noted that Wunderground were receiving their European weather warning data from Meteoalarm. Looking at their website I found that weather warnings from the UK were being reported accurately matching exactly what the UK MetOffice (the source of Meteoalarm’s UK data) were publishing on any given day.

To my disappointment neither Meteoalarm nor the MetOffice published a webservice API for weather warnings. Meteoalarm do, however, provide RSS feeds of weather warnings for each country and region in Europe that they support.

I decided to use Meteoalarm’s RSS feeds to solve my own issue with publishing weather warnings to my website for my local area. However, I knew that directly publishing raw RSS feeds would not be not flexible enough for my needs. I would instead prefer a RESTful JSON formatted web service API which I could call via AJAX.

To this end I’ve written meteo-alarm-weather-warnings. This is a PHP API available on GitHub under the MIT License. It’s primary use case is to make it easy to incorporate the latest MeteoAlarm weather warnings into a web site while not requiring users to directly engage with the underlying RSS feeds. The web service fetches the appropriate RSS feed for a given request and parses and converts it into a consistent JSON formatted reply.

It’s functionality includes:

  1. The ability to query for all weather warnings for all regions within any European country covered by Meteoalarm for today and tomorrow.
  2. The ability to query for weather warnings for any individual region for today and tomorrow.
  3. Custom date/time formats to use for results.
  4. Custom time zone to use for date/times in results (Meteoalarm reports all date/times in CET).

For example, here is a portion of the the raw JSON results from meteo-alarm-weather-warnings for the UK on 31/Dec/2017 when several warnings were in effect:


Click to Enlarge

meteo-alarm-weather-warnings is now incorporated into my own weather web site’s weather warnings page. Here is how it looked rendering results from the web service for my local area on 31/Dec/2017:

meteo-alarm-weather-warnings on website

Click to Enlarge