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.