IP2Country


Translate IPv4 addresses to locate ip address country.
This tool includes IP2Location LITE data available from http://lite.ip2location.com.
Flag ICONS : http://lipis.github.io/flag-icon-css/

3.236.237.61

United States (US)

WEBSERVICE

Details are shown below.

URL


http://api.key-ative.com/ip2location/v1/{IPv4_ADDRESS}
        		

{IPv4_ADDRESS} - IP you're interested

RESPONSE

When requested to my api I will return all IP detail in json format. Here's is sample.


{
	"statusCode":"OK",
	"statusMessage":"",
	"ipAddress":"27.254.36.229",
	"countryCode":"TH",
	"countryName":"Thailand",
	"servertime":"Mon, 18 May 15 09:59:39 +0700",
	"error":false,
	"status":200
}
        		

Try the JSON API from the command line


$curl api.key-ative.com/ip2location/v1/27.254.36.229
{
	"statusCode":"OK",
	"statusMessage":"",
	"ipAddress":"27.254.36.229",
	"countryCode":"TH",
	"countryName":"Thailand",
	"servertime":"Mon, 18 May 15 09:59:39 +0700",
	"error":false,
	"status":200
}
        		

PHP Code

Here's a PHP code example.

Option 1


$url  = "http://api.key-ative.com/ip2location/v1/27.254.36.229";
$json = file_get_contents($url);
if($json){
  $data = json_decode($json);
  var_dump($data);
}
        		

Option 2


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://api.key-ative.com/ip2location/v1/27.254.36.229");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec ($ch);
curl_close ($ch);
$data = json_decode($json);
var_dump($data)