API data different to webpage data??

  • 1
  • Problem
  • Updated 5 years ago
If I look at
the rapid fire page and the weather history page for the same location, the data is the same.
However if I use my api to retrieve a JSON string;
api.wunderground.com/api/my-api/conditions/q/pws:IFINNING3.json
the data is different, the 'precip_1hr_metric' which always remains at zero (despite the 'precip_1hr_in' showing a value!), and the precip_today_metric which shows a different value to the web pages.

How can the data be different from the same source obtained at almost the same time??

From my api;



The rapidfire page;



Weather history page;

Photo of Paul Reed

Paul Reed

  • 23 Posts
  • 7 Reply Likes

Posted 5 years ago

  • 1
Photo of Paul Reed

Paul Reed

  • 23 Posts
  • 7 Reply Likes
Well, I might have found out why the "precip_1hr_metric" is always recorded as zero in my database. Look at the screenshot below (from a Wunderground API call), the "precip_1hr_metric" value is preceded by a 'space', which as a non-numeric value is being rejected and corrupting my system.

Where has the space come from? I've noticed the same error is apparent on other pws sites too, so it appears to be a widespread Wunderground.com glitch, rather than an individual pws posting string error.

I've read in the Upload Protocol Wiki that the rain data is uploaded in 'inches', so presumably it is automatically converted to 'mm' by Wunderground.com which may be where the error originates.
But note that the precip_today_metric does display the value correctly.

I would be grateful if this could be investigated further.

Paul

Photo of Paul Reed

Paul Reed

  • 23 Posts
  • 7 Reply Likes
Well, as Support aren't forthcoming, I suppose I better answer this myself!

Instead of using 'precip_1hr_metric', I'm now using 'precip_1hr_in' and doing the conversion locally. So the php script is now;

$rain_hr_mm = (($parsed_json->{'current_observation'}->{'precip_1hr_in'})*25.4);

The result is now the data is handled correctly by my server, and the metric data is to 2 decimal place instead of being rounded to a whole number by Wunderground.

Paul