API schema data validation

  • 2
  • Problem
  • Updated 8 months 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.
Example:
    "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.
Joe
Photo of Joe Gasper

Joe Gasper

  • 1 Post
  • 0 Reply Likes

Posted 8 months ago

  • 2
Photo of James Anding

James Anding

  • 38 Posts
  • 18 Reply Likes
Just a comment from someone who's been using this service while now.

None of these ideas you propose will ever happen.
They are well thought out and make sense but I would faint dead away if they did any of them.

It's hard enough for them to fix a real bug. Can take weeks to months to years to get some things fixed.
Another reason, If they did this it would most surely break hundreds of users who have already coded
around these issues. Plus, I don't think they would be willing to start a separate api branch  to
accomplish this.

I could write a book with issues with the way the api returns json strings. But it would be just a waste of time.

Good luck though.
Photo of dah

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.