IP Address API Documentation
Sending request to api
curl method: curl https://any.ge/api/ip/api.php?ip=18.221.108.142
results will be: {"name":"United States","code":"US","ccode":"USA"}
Field | Description |
---|---|
name | United States is a country full name |
code | US is a country 2 symbol code |
ccode | USA is a country 3 symbol code |
With JQuery
$.get("https://any.ge/api/ip/api.php?ip=18.221.108.142", function (response) { console.log(JSON.stringify(response, null, 4)); var name = response.name; var code = response.code; var ccode = response.ccode; });
With PHP
$ip = $_SERVER['REMOTE_ADDR']; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, 'https://any.ge/api/ip/api.php?ip='.$ip); $result = curl_exec($ch); curl_close($ch); $obj = json_decode($result); $name = $obj->name; $code = $obj->code; $ccode = $obj->ccode;