Free and easy geoip API thanks to Cloudflare and Heroku. With jQuery: $.getJSON("https://geoip.jasonling.com/",function(a){alert(a)});