29

I'm creating an app (PHP) that takes yahoo weather data from the free RSS feed and correlates it with a colour hex based on data retrieved from the RSS feed. The issue I'm having is finding a way to grab the location code or WOEID without doing it manually.

Yahoos API sends back an RSS feed as long as you provide a WOEID -> http://weather.yahooapis.com/forecastrss?w=4097

Is there an ethical way of doing this? My beginner knowledge tells me I have to write a script that would search yahoo using the term and grab the first WOEID, but I would assume yahoo doesn't want scripts doing this and it seems overcomplicated... If not, are there any alternative APIs that would make this easier on me?

Thanks!

askon
  • 671
  • 2
  • 10
  • 24
  • 1
    For anyone stumbling on this question on 2013: Yahoo! killed WOEID APIs. We posted about this here: http://soup.metwit.com/post/47181933854/an-alternative-to-yahoo-weather-api – Davide R. Apr 08 '13 at 09:34

3 Answers3

64

Why not just use the Yahoo! GeoPlanet service to resolve a place to a WOEID? Or use the YQL service to access GeoPlanet via it's table?

http://where.yahooapis.com/v1/places.q('Barrie CA')?appid=[yourappidhere]

or

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22Barrie%20CA%22&format=xml

No need for scraping.

Cheers

G

(Disclosure; I work for Yahoo! and am part of the group behind WOEIDs and GeoPlanet)

Gary Gale
  • 755
  • 6
  • 5
  • 2
    Thanks Vicchi! You guys do a wonderful job of making it easy for beginners like me to learn! – askon Dec 01 '09 at 22:01
  • 2
    Holy smokes, this answer is class. Just what I was looking for – Drenai Oct 15 '10 at 00:52
  • I get country id, but in wich table is country town? – lolalola Dec 01 '10 at 21:56
  • How can you get the WOEID from Longitude/Latitude using that query.yahooapis.com URL? – barfoon Jan 19 '12 at 04:28
  • Also, looks like the geo.places documentation URL is broken: http://developer.yahoo.com/geo/guide/api-place.html – barfoon Jan 19 '12 at 04:36
  • @Gary How can I make a signed query request on yahoo yql with my client id/secret? I cannot find any traces of such official document by yahoo over the internet. – Choxx Dec 09 '17 at 07:51
  • @Choxx - much as it pains me to say this, I'd look elsewhere to solve your problems. YQL and the YDN sites are a mess of dead links and lots of the YQL tables have vanished. If you still need access to the WOEID data set, there's a mirror of the Geoplanet Data data-sets on the Internet Archive at https://archive.org/search.php?query=geoplanet or alternatively take a look at Mapzen's Whos On First for an actively maintained and supported data set that's definitely inspired by GeoPlanet and also contains (limited) GeoPlanet and WOEID concordance, see https://whosonfirst.mapzen.com/. – Gary Gale Dec 10 '17 at 15:01
  • @GaryGale Thanks for the help. I was having doubt about Yahoo's services. Now you confirmed I was right :D. I'll look into the links you shared. – Choxx Dec 11 '17 at 06:05
  • Hi Gary, I'm using yahoo weather api to get weather information using ('https://weather-ydn-yql.media.yahoo.com/forecastrss?location=delhi&format=json') api, but now i want to get weather info for multiple cities, how can i do this. – Abhishek Apr 13 '20 at 08:24
5

I got some useful information from: http://developer.yahoo.com/geo/geoplanet/

And

http://developer.yahoo.com/geo/geoplanet/guide/api-reference.html#api-countries

  1. Find the WOEID of a significant landmark: http://where.yahooapis.com/v1/places.q('sydney%20opera%20house')?appid=[yourappidhere]

  2. Resolve a WOEID to a place: http://where.yahooapis.com/v1/place/2507854?appid=[yourappidhere]

  3. Find the WOEID of a specific place: http://where.yahooapis.com/v1/places.q('northfield%20mn%20usa')?appid=[yourappidhere]

  4. Obtain a range of WOEIDs that match a given place, ordered by the most likely: http://where.yahooapis.com/v1/places.q('springfield');start=0;count=5?appid=[yourappidhere]

  5. Find the parent of a given WOEID (and return a detailed record): http://where.yahooapis.com/v1/place/638242/parent?select=long&appid=[yourappidhere]

  6. Return the Placename for a given WOEID in a specific language (where it exists): http://where.yahooapis.com/v1/places.q('usa')?lang=fr&appid=[yourappidhere]

  7. To obtain the representation of a place in JSON format: http://where.yahooapis.com/v1/place/2487956?format=json&appid=[yourappidhere]

  8. To obtain a list of geographies that neighbor a specific WOEID: http://where.yahooapis.com/v1/place/12795711/neighbors?appid=[yourappidhere]

Kirk Woll
  • 76,112
  • 22
  • 180
  • 195
NguyenDat
  • 4,129
  • 3
  • 46
  • 46
1

Yahoo! Geo Technologies is pleased to announce the availability of PlaceFinder support in YQL. The geo.placefinder table allows users to make requests to PlaceFinder via YQL queries. The new table provides several different ways to access PlaceFinder. A description of the supported requests and parameters can be retrieved using http://query.yahooapis.com/v1/public/yql?q...&appid=test. Here are a few examples:

Geocoding a street address (1600 Pennsylvania Ave, Washington, DC) using free-form input format:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%221600%20Pennsylvania%20Ave%2C%20Washington%2C%20DC%22&appid=test

Geocoding a street address (701 First Ave, Sunnyvale, CA 94089) using multi-line input format:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20line1%3D%22701%20First%20Ave%22%20and%20line2%3D%22Sunnyvale%2C%20CA%2094089%22&appid=test

Geocoding an airport code (SFO):

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22sfo%22&appid=test

Geocoding a point of interest (POI) in French:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22Eiffel%20Tower%22%20and%20lang%3D%22fr%22&appid=test

Reverse geocoding using geographic coordinates:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%2237.416275%2C%20-122.025092%22%20and%20gflags%3D%22R%22&appid=test

Geocoding a street address (701 First Ave, Sunnyvale, CA 94089) using parsed input format:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20house%3D%22701%22%20and%20street%3D%22First%20Ave%22%20and%20city%3D%22Sunnyvale%22%20and%20state%3D%22CA%22%20and%20postal%3D%2294089%22&appid=test

Determining the nearest cross streets and timezone for an address:

http://query.yahooapis.com/v1/public/yql?q=select%20line1%2C%20line2%2C%20line3%2C%20line4%2C%20cross%2C%20timezone%20from%20geo.placefinder%20where%20text%3D%22701%20First%20Ave%2C%20Sunnyvale%2C%20CA%22%20and%20flags%3D%22T%22%20and%20gflags%3D%22C%22&appid=test

This example illustrates the YQL ability to select only specified fields from the response

OnlyMAJ
  • 819
  • 8
  • 21