having multiple results for the a city forecast

  • 1
  • Question
  • Updated 5 years ago
I am having multiple city name , for example stuttgart germany
api responses the results with city details instead of forecast
how can I select the current city ?
Photo of scankaya

scankaya

  • 1 Post
  • 0 Reply Likes

Posted 6 years ago

  • 1
Photo of GEOSoft

GEOSoft

  • 26 Posts
  • 1 Reply Like
Probably an error in the api call. Post your call and then people can see what is wrong.
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
I know what the issue is. We have 2 WMO id's for that city. I'll talk to our database developer about it. In the meantime, when you get a search like that and need to specify, use the "zmw" field in the city data to make a URL request like this:

http://api.wunderground.com/api/{key}...

That will get you to a single location when you get ambiguous results.
Photo of RxMonitoring

RxMonitoring

  • 2 Posts
  • 0 Reply Likes
I am running into the same thing for alerts/conditions/q/Germany/Koeln.json
I get two results as city information and then have to make another API call using the zmw.
For my purposes I would be content to only ever get the first result (with actual alerts/conditions data).
Is there something I can add to the query string to tell it to "just pick the first one" ?
Photo of WunderWilliam

WunderWilliam

  • 267 Posts
  • 18 Reply Likes
There isn't anything you could add to the string to pick the first one. You could do it on your end, but that would require an additional call after you made the first one.

On the other hand, if you do the call by lat / long instead, we'd always use the closest available station and there wouldn't be an issue with database dupes.