I have noticed that Groupon.com or Zillow.com knows what city I am located in quite reliably and without asking permission.

Does anyone know what they or similar big players do to get your location? Are they using private ip-based databases or something else?

I need to know what city a user is in, are there any online services that I can use to get a user's location for free?

closed as too broad by John Conde Jan 22 '15 at 16:12

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    There is an inherent error rate in any GEOIP database. This is because of the heavy reliance on self-reporting by telecoms, hosting companies, and so on. The rest is extrapolated using a triangulation method and distance estimations based upon ping. In your case, it may be that your telecom is reporting locations accurately. As for me, apparently, I can be in Ohio, Pennsylvania, New York, Florida, and sometimes in New Jersey and others. You can use the GEOIP Lite database at: maxmind.com/en/opensource – closetnoc Jan 22 '15 at 16:22

They are most likely using geolocation by IP address or hostname.

There are many services that provide data for this. One that I know of that's easy to use is http://freegeoip.net. They have an API that you can call 10,000 times per hour to get geolocation data.

For example, if you make an HTTP GET request to http://freegeoip.net/json/stackoverlow.com, you can get data back in multiple formats. This example returns JSON:

    "ip": "",
    "country_code": "US",
    "country_name": "United States",
    "region_code": "NY",
    "region_name": "New York",
    "city": "New York",
    "zip_code": "10004",
    "time_zone": "America/New_York",
    "latitude": 40.689,
    "longitude": -74.021,
    "metro_code": 501

Not the answer you're looking for? Browse other questions tagged or ask your own question.