Retuning multiple cities, ignoring state

  • 1
  • Problem
  • Updated 4 years ago
Hey Guys,

We were getting the weather through the API during our testing phase with no problems at all, and in general are very happy with the service. However, once we rolled it out to production a couple of days ago, we noticed a few failures when trying to get the conditions for a given city/state.

As an example of a request: http://api.wunderground.com/api/88a48...

That url is specifically looking for the 10-day forecast for West Carthage in New York, but the results we get back are very odd:

{
response: {
version: "0.1",
termsofService: "http://www.wunderground.com/weather/a...",
features: {
forecast10day: 1
},
results: [
{
name: "West",
city: "West",
state: "KY",
country: "US",
country_iso3166: "US",
country_name: "USA",
zmw: "41005.6.99999",
l: "/q/zmw:41005.6.99999"
},
{
name: "West",
city: "West",
state: "MS",
country: "US",
country_iso3166: "US",
country_name: "USA",
zmw: "39192.1.99999",
l: "/q/zmw:39192.1.99999"
},
{
name: "West",
city: "West",
state: "TX",
country: "US",
country_iso3166: "US",
country_name: "USA",
zmw: "76691.1.99999",
l: "/q/zmw:76691.1.99999"
}
]
}
}

Now to me this looks like the API is making suggestions for what we want.
The first and obvious issue is the city name...we did not request "West" as a city.
The next issue is that if we go to the wunderground site and ask for weather for West Carthage, New York, we get it.

West Carthage, New York is actually is actually a village within the town of Champion, and when requesting conditions for Champion, there is no problem. However, this is inconsistent because if we request weather for Laveen, Arizona we get it, even though Laveen is a district of Phoenix.

Can someone give me an explanation on this, so that I know how to pass our data?

Thanks,
Paul
Photo of Liberty Devs

Liberty Devs

  • 2 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of John Belmonte

John Belmonte

  • 18 Posts
  • 1 Reply Like
I think the problem is the underscore in the city name.
.../q/NY/West_Carthage.json

use /q/West Carthage.json and see if that doesn't fix the problem.
Photo of John Belmonte

John Belmonte

  • 18 Posts
  • 1 Reply Like
Ignore this post. It is not applicable to your situation.
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
http://www.wunderground.com/cgi-bin/f...

vs

http://www.wunderground.com/q/locid:U...

If you use our Autocomplete API you can get to West Carthage because it takes in more things like town names as opposed to city names. But doing a search for the name West Carthage doesn't work because we don't call that a city we get observations from. I know its weird, that's just the state of it right now. So I recommend the Autocomplete to help you get the city you want.
Photo of Liberty Devs

Liberty Devs

  • 2 Posts
  • 0 Reply Likes
Thanks Brendan, I'll give that a try.

-- Paul