IP-to-Country lookup, for free and 95% accurate
One of my recent posts showed you how to convert an IP address to an IP number so you could do a lookup on a IP-to-Country database.
However, I’ve found the next best thing. Maxmind.com is one of the leaders in GeoIP location and sports a database that is more than 99% accurate. That’s the paid version. For my project though, I only needed to know the country, and had to be pretty accurate.
Welcome Maxmind’s free JavaScript addon API! 95% accurate and does what I want it to do.
1 2 3 | <script type="text/javascript" src="http://j.maxmind.com/app/country.js"></script> var countryCode = geoip_country_code(); alert(countryCode); |
And that’s IT! You don’t have to host the database, you don’t have to do the number conversion yourself and pretty much everything else is taken care for you. The free service also included City lookups! Include and enjoy!
Here’s the link to their site: http://www.maxmind.com/app/javascript_city


































































