0

Is there a way to get Geo location from the IP address of the user?

If user agrees, I collect Geo Location using: navigator.geolocation.getCurrentPosition()

but if the user refuses, I want to get it from the IP address although it is not accurate.

Inbal
  • 909
  • 2
  • 28
  • 46
  • http://stackoverflow.com/questions/391979/how-to-get-clients-ip-address-using-javascript-only – Alex Aug 15 '16 at 09:23
  • Be aware that the free IP lookups have very stringent usage restrictions (certain limits per day/hour) and limited returned data. If you need a reliable and scalable service you would need to pay for one – Rory McCrossan Aug 15 '16 at 09:26
  • @Alex I want to get GEO LOCATION from IP, and NOT the IP itself... – Inbal Aug 15 '16 at 09:42

1 Answers1

2

Yes, you can use an external API such as freegeoip : https://freegeoip.net/

Example of json response :

GET call : http://freegeoip.net/json/2.4.44.12
Where "2.4.44.12" is the IP address

But there are many other API doing the same thing, just look over the web which one you want to use.

Marc
  • 1,350
  • 2
  • 11
  • 29