Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web service to GeoIP [closed]

Tags:

geoip

Is there a reliable web-service that provides an API to turn an IP address into a location, i.e. city, region, country. Willing to pay, but need something solid and reliable.

like image 647
Justin Avatar asked Nov 16 '25 14:11

Justin


1 Answers

My service, http://ipinfo.io includes location information, hostname, network owner and some other details:

$ curl ipinfo.io/8.8.8.8
{
  "ip": "8.8.8.8",
  "hostname": "google-public-dns-a.google.com",
  "loc": "37.385999999999996,-122.0838",
  "org": "AS15169 Google Inc.",
  "city": "Mountain View",
  "region": "CA",
  "country": "US",
  "phone": 650
}

Here's a PHP example:

$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
echo $details->city; // -> "Mountain View"
like image 137
Ben Dowling Avatar answered Nov 19 '25 10:11

Ben Dowling



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!