JSON Web Service for Weather Display Live

I’ve been busy implementing a new website for my weather station over the last few weeks at Wayne’s Weather.

There are a number of new technologies being employed. I’ve ditched my bespoke (and ugly) HTML and instead use Bootstrap for a client responsive UI. Chart and image viewing is now more user-friendly thanks to Lightbox. I have also made extensive use of JQuery to pull in information from various sources and to provide a more dynamic experience.

The functionality of the site has also been extended. There are now more in-depth current readings supporting both metric and imperial measurements, forecasts and weather maps from Wunderground.com for the local area have been integrated and I have added a weather webcam and a weather almanac. I intend to write posts to cover the wunderground and webcam build outs soon.

For now this post will concentrate on an unexpected off-shoot of my efforts: a Web Service that exposes Weather Display Live data.

Weather Display Live

Weather Display (and its equivalents such as MeteoHub) can generate clientraw.txt files containing a weather station’s readings and can upload them to a web server periodically and frequently via FTP (in some cases every minute). The primary purpose of this is to drive a Weather Display Live (WDL) dashboard:

Click to Enlarge

The WDL clientraw.txt format is well documented and I have previously used the HTTP addressable clientraw.txt to drive a custom Android widget and my PiFaceCAD Weather Display Console. The disappointing aspect is WDL itself. Don’t get me wrong it’s an excellent weather dashboard and I still have it available in my new website. The problem with it is that is Flash based which is not as widely supported as it used to be. It’s pretty much not an option for mobile device clients running IOS or Android, for example.

To counter this I wanted my new website to make far greater use of the information contained in the clientraw.txt files outside of WDL dashboard itself. My old weather website made use of PHP to grab weather readings from clientraw.txt and place them into web pages before serving them up to the client. This was an approach I wanted to move away from.

I’d just cut my teeth on using JSON formatted web services with my experience as a client to the Wunderground API. I liked the idea of having a page load its own data from the client side where it could conceivably be mix and match data from various services. I figured it wouldn’t be too difficult to create my own web services to expose WDL data and call them from my own web site.


I settled on using PHP for the implementation for a couple of reasons. Firstly because I’ve used it for server-side processing on-and-off for a few years and know if fairly well. Secondly because I intended to write a general solution which I could open source for others to use and PHP is ubiquitous in the hosting world.

The result was json-webservice-wdlive, a JSON formatted web service API.

The API exposes two URLs. The first URL returns current weather conditions including Temperature, Pressure, Rainfall, Wind, Humidity, Dew Point, Wind Chill, Humidex, Heat Index and UV. The second URL returns a weather almanac for Month-to-Date, Year-to-Date and All Time records. Both JSON and JSONP (enabled with the addition of a callback attribute to the URL) are supported.

Besides exposing the data in the default units found in clientraw the responses also contain many alternative units. For example, clientraw files store wind speeds in knots. The Web Service responses, on the other hand, respond with Bft, knots, km/h, mph, and m/s.


Click to Enlarge

Note that I only expose the data I need for my own purposes (i.e. what my weather station setup supports). However, it would be a simply matter to expand the service calls to add, say, solar measurements or extend the selection of almanac measurements. Anything else WDL clientraw.txt files provide can be exposed, if required, with minor code additions.

I have made the json-webservice-wdlive source code available as a GitHub project. Have a look in the project’s README for installation instructions. json-webservice-wdlive is also running live on my own weather website. You can try it at by clicking on the links below:

Refer to the GitHub project page for more details on the Web Service’s response fields including the different measurement units and number field formatting details.

I also make use of the service in three places on my own website: the Current Conditions, Weather Almanac (pictured below) and the Forecast page where I mix my service’s results with those from the Wunderground web service.


Click to Enlarge

If you have a WDL enabled website feel free to install json-webservice-wdlive to expose your weather data to others and/or to include your information in your own pages.

Explore posts in the same categories: Code Projects, Meteorology, Open Source, Weather Station

Tags: , , , ,

You can comment below, or link to this permanent URL from your own site.

10 Comments on “JSON Web Service for Weather Display Live”

  1. jachencarl Says:

    Hi there!

    Probably a super job. But I cannot get things to work after following the README and having stored all files on my server following the rule to adress the directory of the clientraw.txt file.

    When adressing e.g. http://mydomain/json/src/weather.json the result is the source code of the weather.json file instead of a json file.

    Please help.

    Best regards

  2. waynedgrant Says:

    Hi Jachen,

    It sounds like your server isn’t interpreting the files with .json extensions as PHP5 files. There are a couple of possibilities as to why this is.

    Your server won’t do this by default and requires this step from the README to be carried out:

    Modify your web server to process .json files using PHP. For example, for Apache add the following to your .htaccess file:

    AddHandler application/x-httpd-php5 .json

    Note that PHP5 is also a requirement so make sure that’s installed on your server. Older versions of PHP will not work.

    You can test which version of PHP you have using these steps:


    If you’ve done the above step already and it isn’t working then work with the sysadmins for your domain to work out why the .htaccess change isn’t taking effect.

    In the meantime making copies of the files ending in ‘.json’ and renaming them to have ‘.php’ will work (provided you have PHP5 installed).

    I note that you have ‘src’ in your example path. This suggests that you may be using a copy of the current git repo. Beware this is currently undergoing refactoring. If you aren’t already then use the latest release from:


    Let me know how you get on.

    – Wayne

    • Jachen Says:

      Hi Wayne

      Great Programmer. Thanks a lot for your recent help.

      Your programme assists me tremendously while learning.
      I will continue to watch your nice work and maybe add some of your features to my websites if allowed.

      Meanwhile there is my target to have all weather stuff responsive.
      I also added a seconds field for the time (what a strugle).
      Put intermediately on an old Synology NAS for developments:


      • waynedgrant Says:

        Hi Jachen,

        Nice. I didn’t expose seconds because my setup doesn’t update more than once a minute. Next time I update the source I’ll add seconds in for others with better weather station setups to take advantage of.

  3. Juha Myllys Says:


    Would it be possible to refer client raw directory on different server on my lan? I tried to define CLIENT_RAW_DIRECTORY as http://meteoplug.local/uploads but weather.json returns just empty data…

    – Juha –

    • waynedgrant Says:

      Hi Juha,

      The CLIENT_RAW_DIRECTORY can only be used to place your clientraw files in a different directory from the one where the web service is installed on the same server. It doesn’t support placing them on a different server.

      • Juha Myllys Says:

        Bummer, guess I have to share & mount the meteoplug dir then.

        Second question: I have 10 extra indoor sensors and their data is available at clientraw.txt but it seems that extra sensor data is not shared by the json webservice by default. What changes (and where) should be done on json to deliver extra sensor data?

      • waynedgrant Says:

        If you plan on forking the source and know php then you’ll want to add the extra fields to ClientRaw.php using the existing pattern of consts and getters. The new fields should be made available via weather.json which will require you to change WeatherSource.php. Again, follow the existing pattern.

  4. ozzippl Says:

    Really keen to get this working as it’s just what I’m after. I’m using a Raspberry Pi and have installed PHP5. Ive tried putting the src files into /srv/www but they dont seem to be recognised as PHP files. I think I may need to install Apache or something but not sure if that would conflict with the Meteohub webs server. Any guidance appreciated. Thanks.

    • waynedgrant Says:

      First of all take json-webservice-wdlive out of the equation and confirm if php is working at all under /srv/www. You can do this by installing a phpinfo test file there and hitting it with a web browser:


      If this shows php5 is not working then I won’t be able to offer any further advice. I use meteohub myself but its on a SheevaPlug and anyway I have json-webservice-wdlive running via web hosting.

      However, if this confirms php is working in that location then it’s probably the extensions I’ve chosen for the endpoint files. I add a handler in Apache to have it process .json files as php:

      AddHandler application/x-httpd-php5 .json

      A simpler solution for you would be to simply rename all the .json files as .php.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: