API schema data validation

  • 2
  • Problem
  • Updated 3 years ago
Problem 1)  
Using API to return XML is missing XML declaration.
Solution 1) 
Please include as first line: 
<?xml version="1.0"?>
or with encoding (not sure what you use - another problem)
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="ISO-8859-1"?>

Problem 2) 
Using API to return JSON using inconsistent schema.
Some values will be returned as a number and sometimes as a string - scheme based, typed parsing fails.
    "heat_index_f": "NA",
    "heat_index_c": "NA",
and sometimes
    "heat_index_f": 105,
    "heat_index_c": 40,

It would be preferable to return an empty value instead of the string "NA".
The scheme can then be coded as: 
        "heat_index_f": {
          "type": ["number","null"]
        "heat_index_c": {
          "type": ["number","null"]

Currently, I have to set the schema as, which works, but makes for extra post-processing: 
        "heat_index_f": {
          "type": ["number","string"]
        "heat_index_c": {
          "type": ["number","string"]

There is other data I would like to see as numbers instead of strings.
For example: 
"relative_humidity": "59%",
"elevation": "120 ft"
could be:
"relative_humidity_pct": 59,
"elevation_ft": 120
"elevation_m": 36.6

Unfortunately, these values are in quotes, making them strings.
"pressure_mb": "1007",
"pressure_in": "29.74"
"pressure_trend": "0"
"feelslike_f": "102",
"feelslike_c": "39",
"visibility_mi": "6.2",
"visibility_km": "10.0"
"UV": "5",
"precip_1hr_in": "-9999.00",
"precip_1hr_metric": "--",
"precip_today_in": "0.00",
"precip_today_metric": "0.0"

Also, it would be great to get the schema documented like https://www.apixu.com/doc/current.aspx

I would be great to get an api.wunderground.com/api2 with a consistent schema that we can move over to as we rework our code to remove work-arounds.

Thank you.
Photo of Joe Gasper

Joe Gasper

  • 1 Post
  • 0 Reply Likes

Posted 3 years ago

  • 2
Photo of dah


  • 5 Posts
  • 3 Reply Likes
you know an API's in trouble when the sales team can't be reached (a few posts down).  I too have been disappointed by the lack of attention raised issues seem to get.