Wunderground API-国家/州/城市组合问题

问题描述:

我使用Google Maps Place API限于城市研究,因此我得到的城市,州和国家加上conditionsforecast10day Wunderground APIWunderground API-国家/州/城市组合问题

似乎有时我已经建立了Wunderground API端点问题。

当我在短短一个国家提供一个城市,我有这个端点:

http://api.wunderground.com/api/ {}键/conditions/q/IT/Milan.json

和它的工作原理像一个魅力。

当我知道我在寻找的城市可在很多国家,我的“状态”值添加到终点,就像这样:

http://api.wunderground.com/api/ {}键/环境/ Q/US /PA/Lancaster.json

问题是当我在印度寻找新德里(在这一点上恐怕也为其他城市):

的http:// API。 wunderground.com/api/{KEY}/条件/ Q/IN/DL/NewDelhi.json

在这种情况下的反应是这样的:

"error": { 
    "type": "querynotfound", 
    "description": "No cities match your search query" 
} 

但是如果我通过 “ZMW” 调用的参数条件/新德里在印度

http://api.wunderground.com/api/ {}键/conditions/q/zmw:00000.1.42182.json

我看到这个 “DISPLAY_LOCATION” 对象:

"city":"New Delhi/Safdarjung", 
"state":"DL", 
"state_name":"India", 
"country":"IN" 

所以,看起来正式的我的端点是正确的。 我在错什么?

PS:我使用的是Google Maps Place API,因为它也是UI准备好的。 :)

我已联系Wunderground tech support

呃 - 正如他们告诉我的 - 他们的API有点不一致,所以对于美国以外的地方,最好的解决方案是通过lat/lng值进行API调用,以确保始终具有相同的响应结构。

对我而言,通过Google Maps Places可能是因为我保存了我正在搜索的城市的纬度/经度值。

所以,你可以建立这个端点:

https://api.wunderground.com/api/ {}键/环境/ Q/{纬度},{} LNG。json

它的功能就像一个魅力!