Geocode an IP address?

Tim picture Tim · Jul 12, 2010 · Viewed 55.5k times · Source

Does anyone know of any open RESTful API that I can call to geocode a user's IP to the latitude and longitude?

Ideally, it would be something like: http://google.com/geocode_api/?IP=1.2.3.4 and it would return the latitude and longtitude.

Answer

Stefan Haberl picture Stefan Haberl · Jun 20, 2013

Another free REST API with city accurate information would be http://freegeoip.net Requests are fairly straight forward. You would use something like

http://freegeoip.net/{format}/{ip_or_hostname}

to geocode an IP address, where format can be csv, xml or json. Their website has all the details.

[UPDATE:] FreeGeoIP.net was not continuously available in the past as a public service. The software was, however, always open source and is available on Github. It's fairly easy to get your local installation running using Docker, if you need a highly reliable service or your use case exceeds the current quota of 15.000 requests/hour.