RESTful API Documentation for IP geolocation
Geolocation IPv4 and IPv6 compatible, multi output formats.
Get your API Key ready (click here if you don't have one) and simply follow the documentation to perform requests.
(You can get an API Key for free, upgrade anytime to Premium for unlimited requests.)
JSON Response formatServer side
The 2 variable elements of this URL (address_ip and your_api_key) have to be replaced by some values before performing the request.
A correct URL would be for exemple:
https://ip-get-geolocation.com/api/json/35.188.125.133?key=f25a2fc72690b780b2a14e140ef6a9e0
or if your are using IPv6:
https://ip-get-geolocation.com/api/json/5800:10C3:E3C3:F1AA:48E3:D925:D494:AAFF?key=f25a2fc72690b780b2a14e140ef6a9e0
Variables description
Name | Description |
---|---|
address_ip *
string
(query)
|
Specify the ip address you want to geolocalize. IPv4 or IPv6 format. |
your_api_key *
string
(query)
|
Specify your API Key. (It is sent to you by Email when you register) |
Response on success
Field name | Description |
status |
Equal to the string "success" |
as |
AS number and name, separated by space |
country |
Country name |
countryCode |
2 digits country code |
city |
City name |
isp |
Internet service provider name |
lat |
Latitude GPS coordinate |
lon |
Longitude GPS coordinate |
org |
Organization name |
query |
The IP address you submited |
region |
2 digits region code |
regionName |
Region name |
timezone |
City timezone |
zip |
Postal zip code |
Response example on success |
{"as":"AS15169 Google LLC","city":"Newark","country":"United States","countryCode":"US","isp":"Google Cloud","lat":40.7357,"lon":-74.1724,"org":"Google Cloud","query":"35.188.125.133","region":"NJ","regionName":"New Jersey","status":"success","timezone":"America/New_York","zip":"07175"} |
Response on failure
Field name | Description |
status |
Equal to the string "fail" |
msg |
Contains the reason of the failure, basically if your suscription runs out, or if you reach limitations on free plan. |
Response example on failure |
{"status":"fail","msg":"This API Key does not exist"} |
XML Response formatServer side
The 2 variable elements of this URL (address_ip and your_api_key) have to be replaced by some values before performing the request.
A correct URL would be for exemple:
https://ip-get-geolocation.com/api/xml/35.188.125.133?key=f25a2fc72690b780b2a14e140ef6a9e0
or if your are using IPv6:
https://ip-get-geolocation.com/api/xml/5800:10C3:E3C3:F1AA:48E3:D925:D494:AAFF?key=f25a2fc72690b780b2a14e140ef6a9e0
Variables description
Name | Description |
---|---|
address_ip *
string
(query)
|
Specify the ip address you want to geolocalize. IPv4 or IPv6 format. |
your_api_key *
string
(query)
|
Specify your API Key. (It is sent to you by Email when you register) |
Response on success
Field name | Description |
status |
Equal to the string "success" |
as |
AS number and name, separated by space |
country |
Country name |
countryCode |
2 digits country code |
city |
City name |
isp |
Internet service provider name |
lat |
Latitude GPS coordinate |
lon |
Longitude GPS coordinate |
org |
Organization name |
query |
The IP address you submited |
region |
2 digits region code |
regionName |
Region name |
timezone |
City timezone |
zip |
Postal zip code |
Response example on success |
<?xml version="1.0" encoding="UTF-8"?> |
Response on failure
Field name | Description |
status |
Equal to the string "fail" |
msg |
Contains the reason of the failure, basically if your suscription runs out, or if you reach limitations on free plan. |
Response example on failure |
<?xml version="1.0" encoding="UTF-8"?> |
CSV Response formatServer side
The 2 variable elements of this URL (address_ip and your_api_key) have to be replaced by some values before performing the request.
A correct URL would be for exemple:
https://ip-get-geolocation.com/api/csv/35.188.125.133?key=f25a2fc72690b780b2a14e140ef6a9e0
or if your are using IPv6:
https://ip-get-geolocation.com/api/csv/5800:10C3:E3C3:F1AA:48E3:D925:D494:AAFF?key=f25a2fc72690b780b2a14e140ef6a9e0
Variables description
Name | Description |
---|---|
address_ip *
string
(query)
|
Specify the ip address you want to geolocalize. IPv4 or IPv6 format. |
your_api_key *
string
(query)
|
Specify your API Key. (It is sent to you by Email when you register) |
Response on success
Field name | Description |
status |
Equal to the string "success" |
as |
AS number and name, separated by space |
country |
Country name |
countryCode |
2 digits country code |
city |
City name |
isp |
Internet service provider name |
lat |
Latitude GPS coordinate |
lon |
Longitude GPS coordinate |
org |
Organization name |
query |
The IP address you submited |
region |
2 digits region code |
regionName |
Region name |
timezone |
City timezone |
zip |
Postal zip code |
Response example on success |
as,city,country,countryCode,isp,lat,lon,org,query,region,regionName,status,timezone,zip |
Response on failure
Field name | Description |
status |
Equal to the string "fail" |
msg |
Contains the reason of the failure, basically if your suscription runs out, or if you reach limitations on free plan. |
Response example on failure |
status,msg |
PHP serialized Response formatServer side
The 2 variable elements of this URL (address_ip and your_api_key) have to be replaced by some values before performing the request.
A correct URL would be for exemple:
https://ip-get-geolocation.com/api/serializedphp/35.188.125.133?key=f25a2fc72690b780b2a14e140ef6a9e0
or if your are using IPv6:
https://ip-get-geolocation.com/api/serializedphp/5800:10C3:E3C3:F1AA:48E3:D925:D494:AAFF?key=f25a2fc72690b780b2a14e140ef6a9e0
Variables description
Name | Description |
---|---|
address_ip *
string
(query)
|
Specify the ip address you want to geolocalize. IPv4 or IPv6 format. |
your_api_key *
string
(query)
|
Specify your API Key. (It is sent to you by Email when you register) |
Response on success
Field name | Description |
status |
Equal to the string "success" |
as |
AS number and name, separated by space |
country |
Country name |
countryCode |
2 digits country code |
city |
City name |
isp |
Internet service provider name |
lat |
Latitude GPS coordinate |
lon |
Longitude GPS coordinate |
org |
Organization name |
query |
The IP address you submited |
region |
2 digits region code |
regionName |
Region name |
timezone |
City timezone |
zip |
Postal zip code |
Response example on success |
a:14:{s:2:"as";s:18:"AS15169 Google LLC";s:4:"city";s:6:"Newark";s:7:"country";s:13:"United States";s:11:"countryCode";s:2:"US";s:3:"isp";s:12:"Google Cloud";s:3:"lat";d:40.7357;s:3:"lon";d:-74.1724;s:3:"org";s:12:"Google Cloud";s:5:"query";s:14:"35.188.125.133";s:6:"region";s:2:"NJ";s:10:"regionName";s:10:"New Jersey";s:6:"status";s:7:"success";s:8:"timezone";s:16:"America/New_York";s:3:"zip";s:5:"07175";} |
Response on failure
Field name | Description |
status |
Equal to the string "fail" |
msg |
Contains the reason of the failure, basically if your suscription runs out, or if you reach limitations on free plan. |
Response example on failure |
a:2:{s:6:"status";s:4:"fail";s:3:"msg";s:27:"This API Key does not exist";} |
PHP SDK
Click here to download the single file PHP class that implements the API (PHP version >=5)
After you have downloaded the class, copy the file into your project directory, and try the following examples:
<?php include 'MasterClass_ip2location-api-v1.0.php'; $APIKey = 'PUT_HERE_YOUR_API_KEY'; //Create the object $ip2locationapiObject = new ip2locationapi($APIKey, 'json', '1.152.109.38'); //Exemple 1: //Perform the request and get the JSON result converted into a PHP Array $ip2locationapiArray = json_decode($ip2locationapiObject->performRequest(), true); echo '<table>'; foreach($ip2locationapiArray as $k=>$v){ echo '<tr><td>'.$k.'</td><td>'.$v.'</td></tr>'; } echo '</table><hr/>'; //Exemple 2: //Perform the request and get the PHP array from serialized answer $ip2locationapiObject->setOutputFormat('serializedphp'); $ip2locationapiObject->setLookupIP('47.247.246.47'); $ip2locationapiArray2 = unserialize( $ip2locationapiObject->performRequest() ); echo '<table>'; foreach($ip2locationapiArray2 as $k=>$v){ echo '<tr><td>'.$k.'</td><td>'.$v.'</td></tr>'; } echo '</table>'; ?> |
AJAX callClient side
On client side, the calls to the API are free, you can integrate the functionality right now, follow this exemple:
Exemple HTML/Jquery |
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>ip-get-geolocation.com Geolocation Demo</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <table id="GeoResults"></table> <script> $.getJSON("http://ip-get-geolocation.com/api/json/35.188.125.133", function(data) { var table_body = ""; $.each(data, function(k, v) { table_body += "<tr><td>" + k + "</td><td><b>" + v + "</b></td></tr>"; }); $("#GeoResults").html(table_body); }); </script> </body> </html> |
For a live exemple, click here
Javascript Function CallbackClient side
On client side, the calls to the API are free, you can integrate the functionality right now, follow this exemple:
Exemple HTML/Javascript |
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>ip-get-geolocation.com Geolocation Demo</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <table id="GeoResults"></table> <script> function myFunction(theObject){ var table_body = ""; for (var prop in theObject) { if(!theObject.hasOwnProperty(prop)) continue; table_body += "<tr><td>" + prop + "</td><td><b>" + theObject[prop] + "</b></td></tr>"; } $("#GeoResults").html(table_body); } </script> <script src="//ip-get-geolocation.com/api/json/35.188.125.133?callback=myFunction"></script> </body> </html> |
For a live exemple, click here
NOTICE:
Our system will automatically ban any IP addresses doing over 50 requests a day. To unban your IP click here
On server side with your API key, the free plan offers you a great solution to test the service while you develop your project.
The Free plan has a limitation of 120 requests per minute and 10 000 a month. You can perform requests from as many server IP as you wish.
The Premium unlimited plan gives you an unlimited number of requests per minute as well as per month, and the most reliable availability of service.