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.
Geocoding is the process of translating an IP address to a physical location. Geocoding is an imprecise science. It works by looking up an IP address in a database. Databases use a variety of information sources to link IPs and locations, such as tracing web traffic and ownership of IPs.
If you IP geolocation is wrong, it is because the IP database has mapped your location incorrectly. IP geolocation database providers do updates frequently and your location may be fixed in the next update.
IP-based geolocation services provide 55 percent to 80 percent accuracy for a user's region or state. And they provide 50 percent to 75 percent accuracy for a user's city. In practice, the actual accuracy may vary from provider to provider and depending on the location of the device.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With