Search code examples
yqlyahoo-api

Yahoo YQL: find city WOEID by coordinates


How to get city's WOEID if I know latitude and longitude of city using YQL?


Solution

  • Using the YQL console, you can search for the nearest place with a 'placeTypeName.code' of 7

    http://developer.yahoo.com/yql/console/

    SELECT * FROM geo.places WHERE text="{$seedLat}, {$seedLong}" AND placeTypeName.code = 7
    

    The REST query for this query would look something like;

    http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20geo.places%20WHERE%20text%3D%22{$seedLat}%2C%20{$seedLong}%22%20AND%20placeTypeName.code%20%3D%207&format=json&diagnostics=true&callback=
    

    Obviously replacing $seedLat and $seedLong with your own co-ordinates :)