Any Reliable API available to determine User's city and country from IP address

Heyy guys

I wanted to check if anyone knows of a reliable API that we can use to determine the user's city and country from his IP address.

My search on Google led to

It seems perfect but my only concern is the reliability of this service. Does google have anything like this. If you know any other Free or paid API's that help determine user's location from his IP - please let me know



I've used and found it really good.

MaxMind has a lite version of their ip2country and ip2city databases:

If you don't mind hosting the database yourself, it's free. The paid services are more accurate.

They also provide web services for querying, but it is not free:

Consider using geoplugin, it provides the most information from a single line PHP code, but requires a connection to the server for every request (and it is free).

Examples :

Json :

geoplugin_request: "",
geoplugin_status: 200,
geoplugin_city: "Mountain View",
geoplugin_region: "CA",
geoplugin_areaCode: "650",
geoplugin_dmaCode: "807",
geoplugin_countryCode: "US",
geoplugin_countryName: "United States",
geoplugin_continentCode: "NA",
geoplugin_latitude: "37.419201",
geoplugin_longitude: "-122.057404",
geoplugin_regionCode: "CA",
geoplugin_regionName: "California",
geoplugin_currencyCode: "USD",
geoplugin_currencySymbol: "$",
geoplugin_currencySymbol_UTF8: "$",
geoplugin_currencyConverter: 1

Xml :

<geoplugin_city>Mountain View</geoplugin_city>
<geoplugin_countryName>United States</geoplugin_countryName>

Other options

Google has free service

Every IP geolocation depends on records submitted by the ISP. This will never be completely reliable because many ISPs submit location of their office instead of physical locations of their subnets which may be in a different city or even country.

In a sense, you can't reliably know the location of a user. Using the tips the other answers provide will give you the geolocation of an IP, but there's no way to know that that IP address in New York USA isn't being accessed through a VPN from someone on a business trip to London, UK, or whether someone's using an anonymizing service like Tor.

Does google have anything like this.

No, Google does not provide a service similar to this. (note that the answer here which claims that it does provide it, leads to nowhere).

Any other Free or paid API's that help determine user's location from his IP

First of all it is hard to speak about reliability of such service. Most of the services rely on ISP to get their data and ISP not always provide reliable data. Moreover because I assume that you basically cares about the location of your user (and not what location his IP belongs), the user can decide to hide his location either through VPN, Tor or other anonymisers.

In some of your comments, I have seen that by reliable you means uptime of the API provider. If so, than I would recommend MaxMind's GeoIP2. First of all, I have seen this site for long time, they are updated pretty often (last update 1-st April 2014), moreover if you are so afraid of downtime - you can download their database and do not rely on them (also they are free).

Another service I actually like is less known and opensource (it partially relies on data from MaxMind). I have used it only a few times, so I can not say about it's uptime, but I really like theirs API. It is so simple, that it is hard to come up with simpler: 

or like this

will give you

"isp":"Tilaa V.O.F.",

I think that these two services are pretty enough to get normal information for your visitors. But one important thing. If you really need to know where you users came from - why not to ask them with html5 geolocation? Here is a nice example, but you can go further (ask them if the location is correct and give them ability to change it). I know that in your case you need only Country/City, but may be other people will need it.

P.S. Nov 2015. Now that costs money to use, I found another service that is currently free:

Need Your Help

Fabric authentication with kerberos

python kerberos fabric

I'm trying to write a fabric function that puts a script on a remote host and runs it as root. I don't have the root password to login to the machine, nor am I a sudoer, but I do have a root princi...

Read all internal memory images in android though mediastore

android android-gallery android-image mediastore

i am able to read all external images though mediastore in Android, but i want to read all images of internal memory also.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.