7
// Get woeid by lati/long
            HttpGet hg = new HttpGet(
                        "http://where.yahooapis.com/geocode?location=" + latlon + "&flags=J&gflags=R)");
            HttpClient hc = new DefaultHttpClient();
            HttpResponse weatherHR = hc.execute(hg);

            if (weatherHR.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
                if (DEBUG)
                    Utils.log("", "Location != HttpStatus.SC_OK");
                return null;
            }

I used this API and it work ok before, but It return a error since today, the HttpStatus.SC_OK is not OK. Has this API been closed? Thanks.

herbertD
  • 10,657
  • 13
  • 50
  • 77

5 Answers5

10

Yahoo has moved to paid service called BOSS but they do offer a non-commercial service:

Non-Commercial usage of Yahoo Geo API's

Yahoo! continues to fully support developer applications built on top of Placefinder and PlaceSpotter in non-commercial settings. Both services are available to you via YQL and rate limited to 2000 queries per table. Learn more about using the Placefinder and Placespotter YQL tables.

Using Placefinder you can reverse lookup a latitude and longitude:

http://developer.yahoo.com/yql/console/?q=select%20*%20from%20geo.placefinder%20where%20text%3D%2237.416275%2C-122.025092%22%20and%20gflags%3D%22R%22

which can be converted into a json request:

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

Community
  • 1
  • 1
Cas
  • 6,123
  • 3
  • 36
  • 35
6

Yes, it's closed, give a look here: http://soup.metwit.com/post/47181933854/an-alternative-to-yahoo-weather-api

beddamadre
  • 1,583
  • 2
  • 19
  • 40
  • 3
    Yahoo! weather APIs is DEAD at 3rd April, 2013. – herbertD Apr 07 '13 at 02:02
  • Yahoo has moved to a paid [BOSS](http://developer.yahoo.com/boss/geo/) service but your alternative is also a paid service simply with a free trial offer until June. – Cas Apr 18 '13 at 11:06
  • @Cas We have 200 calls per ip that means that you can implement the service client-side for free, for n-clients, without authentication! We are about to change it in a couple of day with some cool stuff and plans (free!) – beddamadre Apr 22 '13 at 13:09
  • metwit is closed as well – Soren Feb 11 '17 at 17:26
1

A city can also be used as location as follows:

select * 
from weather.forecast 
where woeid in (
    select woeid 
    from geo.places(1) 
    where text="frankfurt"
) and u="c"

Where "frankfurt" can be replaced with any location of choice.

DB5
  • 13,553
  • 7
  • 66
  • 71
Istvan
  • 1,219
  • 1
  • 8
  • 9
1

To get the Yahoo Weather WOEID by latitude and longitude, you can use this

https://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%3D%22(20,34)%22%20limit%201&diagnostics=false&format=json

And you will receive a response like the following:

{
  "query":{
    "count":1,
    "created":"2017-03-17T20:34:50Z",
    "lang":"es-AR",
    "results":{
      "place":{
        "woeid":"1435509"
      }
    }
  }
}
0

If still someone need answear. You have basic URL:

https://query.yahooapis.com/v1/public/yql?q=

Now you have to make correct YQL statement (replace city with your city name) e.x.

select * from geo.places where text="city"

Now you have to encode to URI. You can use javascript method: encodeURIComponent(). Then you have to merge basicURL and encoded YQL statement and

&format=json

So example of the whole link for San Francisco will be:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22san%20francisco%2C%20ca%22&format=json

Now from response you have to get WOEID number. You can get it by: query>results>place>[0]>woeid

So in Javascript it will be something like:

const woeidNumber = responseObject['query']['results']['place'][0]['woeid'];
Mieszczańczyk S.
  • 857
  • 1
  • 9
  • 16