News for hackers. Stuff that matters.
Re:WikiMedia's Geo IP Lookup JSONP call by neilk on Sunday July 10, 2011 @04:31PM (#2748553)
Hey folks, just FYI, I work there and this is not intended to be a public API for anyone to use. As others have pointed out, it's trivial to set up such a service yourself anyway.

I know the security-minded among you are going to start complaining that it would be easy to add a nonce, but we'd rather avoid that. Our strategy is to serve virtually everything from cache.

Re:WikiMedia's Geo IP Lookup JSONP call by njl on Sunday July 10, 2011 @03:27PM (#2748403)
Doing the IP lookup yourself isn't very hard. The nginx HttpGeoIPModule[1] will do a lookup on the MaxMind databases for you. I used it in my weekend hack, http://spotwoo.com. Doesn't take very long to set up, very easy to use.

[1] http://wiki.nginx.org/HttpGeoIPModule

Re:WikiMedia's Geo IP Lookup JSONP call by nl on Sunday July 10, 2011 @07:18PM (#2748867)
Interestingly, the latest version of Google AppEngine automatically geolocates every request (to the country level anyway)

All user request have an X-AppEngine-Country header which contains the ISO-3166-1 alpha-2 country code for the user, based on the IP address of the client request.

(from Version 1.5.1 http://code.google.com/p/googleappengine/wiki/SdkReleaseNote...)

Re:WikiMedia's Geo IP Lookup JSONP call by crescentfresh on Sunday July 10, 2011 @03:19PM (#2748385)
The payload is not JSONP and strikes me as a bit impractical:

    Geo = { /* object literal */ }
I assume this service is meant to be consumed via <script> tag injection. Without a JSONP-style callback parameter, what are consumers to do, inject-then-poll until a "Geo" object is found in the global scope?
Re:WikiMedia's Geo IP Lookup JSONP call by judofyr on Sunday July 10, 2011 @03:23PM (#2748396)

    <script src="http://geoiplookup.wikimedia.org/"></script>
    <script>geoloaded()</script>
    </body></html>
Re:WikiMedia's Geo IP Lookup JSONP call by crescentfresh on Sunday July 10, 2011 @04:02PM (#2748482)
D'oh!
Re:WikiMedia's Geo IP Lookup JSONP call by tybris on Tuesday July 12, 2011 @04:54AM (#2754060)
The approach of dynamically generating a callback script is more robust than pure JSONP. If your URL returns an error (e.g., 404), you immediately notice, instead of waiting for the time-out. These days, my usual approach looks something like this in flight:

    <script type="text/javascript">
        var response = undefined;
    </script>
    <script type="text/javascript" src="...">
       // response = { .... };
    </script>
    <script type="text/javascript">
       _callbacks[1234](response); // response == undefined means error
       response = undefined;       // allow garbage collection
    </script>
    
It's a bit more administration, but I really like not having to worry about dynamic callback names, delayed errors, or non-existent callback functions any more.
Re:WikiMedia's Geo IP Lookup JSONP call by tybris on Sunday July 10, 2011 @03:47PM (#2748445)
That's trivial to set up yourself with Maxmind's GeoLite Database.

http://www.maxmind.com/app/geolitecity

Re:WikiMedia's Geo IP Lookup JSONP call by abava on Sunday July 10, 2011 @05:12PM (#2748645)
It is not JSONP. You have to analyze JavaScript variable: http://servletsuite.com/geoip.htm
Re:WikiMedia's Geo IP Lookup JSONP call by qeorge on Sunday July 10, 2011 @07:04PM (#2748829)
GeoPlugin.net has a city-level, free version of this that's actually intended for public use:

http://www.geoplugin.net/json.gp

Other formats here: http://www.geoplugin.com/webservices

Have been using it in production now for several months, works great.

Re:WikiMedia's Geo IP Lookup JSONP call by travelemployee on Sunday July 10, 2011 @04:39PM (#2748570)
I actually implemented a lucene search index in case you might want to do it in lucene...

https://github.com/krickert/IPAddressZipCodeStateCountryLuce...

It downloads one of the many free DBs of IP addys and makes it into an index. You can do geo spatial searching APIs with IP addys.. Fun stuff.

Re:WikiMedia's Geo IP Lookup JSONP call by leecn on Sunday July 10, 2011 @07:12PM (#2748851)
If anyone wants something similar I built a version of this a few weeks ago: https://github.com/contrast/geoip_sinatra

It's a sinatra app which uses the MaxMind data, typically responds in < 1ms, and it has caching built in (if you deploy it to heroku).

Re:WikiMedia's Geo IP Lookup JSONP call by Inufu on Sunday July 10, 2011 @02:20PM (#2748262)
Not very accurate for me. Wrong by about 400km. (that's basically from one end of my country to the other end)
Re:WikiMedia's Geo IP Lookup JSONP call by harisenbon on Sunday July 10, 2011 @10:05PM (#2749187)
Same for me as well. I'm being detected all the way in another prefecture.

I find it strange that depending on the device, that I will be detected in different areas (even within the same service).

For example: Google Maps says I'm at a park about a 10 minute drive from my current location. But if I view the mobile version of it on my iPod, it can find me to the room of the building I am in.

Anything that's not google or apple puts me in Hamanako, which is a 2 hour drive on the expressway.

Re:WikiMedia's Geo IP Lookup JSONP call by yahelc on Sunday July 10, 2011 @03:44PM (#2748439)
It's off by ~10 miles, but since there are several million people between me and where it thinks I am, that's not particularly disturbing.
Re:WikiMedia's Geo IP Lookup JSONP call by conradev on Sunday July 10, 2011 @02:45PM (#2748325)
For me, it was wrong by about 50 miles.
Re:WikiMedia's Geo IP Lookup JSONP call by aaronharder on Sunday July 10, 2011 @03:05PM (#2748363)
Cool. But what are the terms of use around this one?
Re:WikiMedia's Geo IP Lookup JSONP call by dermatthias on Sunday July 10, 2011 @03:42PM (#2748435)
been there, done that: http://ip.beached.org ;)
Re:WikiMedia's Geo IP Lookup JSONP call by lost-theory on Sunday July 10, 2011 @04:06PM (#2748494)
But that's not JSONP.
Re:WikiMedia's Geo IP Lookup JSONP call by dermatthias on Sunday July 10, 2011 @04:11PM (#2748506)
Oh, that is correct. Sorry, I need to read the headline more carefully. Missed the 'P'.
Re:WikiMedia's Geo IP Lookup JSONP call by VMG on Sunday July 10, 2011 @02:13PM (#2748239)
Which method are they using?
Re:WikiMedia's Geo IP Lookup JSONP call by _delirium on Sunday July 10, 2011 @02:44PM (#2748322)
Unless it's changed recently (I haven't followed the discussion since last year) it's using the free version of the MaxMind IP->city database (http://www.maxmind.com/app/geolitecity).

I can't seem to find the relevant mailing list threads, but here's some evidence of ad-hoc accuracy testing last August: http://meta.wikimedia.org/wiki/MaxMindCityTesting

Re:WikiMedia's Geo IP Lookup JSONP call by dangrossman on Sunday July 10, 2011 @02:39PM (#2748312)
Re:WikiMedia's Geo IP Lookup JSONP call by roryokane on Sunday July 10, 2011 @02:35PM (#2748297)
Well, it can’t be the JavaScript location API, because there’s no JavaScript on that page, and anyway my browser would ask me if the page wanted to use my location. The only other method I know of that relies on information the site could get just by my visiting the page is looking the IP address up in a database of IP addresses and locations.
Re:WikiMedia's Geo IP Lookup JSONP call by neilk on Sunday July 10, 2011 @04:05PM (#2748493)
I work there. It's MaxMind.
Re:WikiMedia's Geo IP Lookup JSONP call by tantalor on Sunday July 10, 2011 @02:37PM (#2748303)
Gonna guess Geo IP lookup.