GoNew     GBP EUR USD
 
IP To Country Database & API
HTTP API Access

 

Contents:

Our HTTP API solution enables you to make requests to our API server from your website to gain country information from a given IP Address.

 

The benefits of using our online api is that we do all the hard work...

  • Update the information automatically every week.
  • Parse the required information from the 5 global official sources into a standard format and into one single database.

Use of our API is FREE the only restiction is that you have a quota of 500 calls per hour, which should be plenty for most applications.

Should you need a larger quota then contact support, we look at each case individually.

Alternatively, why not purchase the database and create your own local application. Find out more...

 

Getting Started

To use the API you need to register a FREE account with GoNew. Once you have done that you can access your Control Panel and Setup Your API Access.

 

After your API access has been setup, you need to make a note of your GoNew AccountID and the API Access Key. These to details are used to authenticate you API calls to our server.

 

Additionally, you can also setup an IP Lock to restrict API calls. So that the calls can only be made from certain IP addresses. (EG: the IP address of your Webserver)

 

HTTP API Specification :

Currently the is only one api command, implemented.

ip2c:

This is the command to obtain country code and country name from an IP address.

 

Syntax:

http://api.gonew.co.uk/ip2c/ip2c.php?u=AccountID&k=APIKEY&ip=IPADDRESS

 

Parameters:

u = Your GoNew Account ID

k = Your IP To Country API Access Key

ip = The IP address to lookup

 

Return Values:

On success the results returned are in the following format:

OK:\n
ip|countrycode|countryname\n

 

Where ip is the ip that was sent in the request, countrycode is the 2 letter ISO3166 uppercase code for the country (EG: US), countryname is the full country name in uppercase (EG: UNITED STATES).

 

On error the results returned are in the following format:

ERR: errornumber, errordescription\n

 

Possible Error Codes

errornumber errordescription comment
1 Bad Method Only GET Requests are supported.
2 Server Error Error on the side of the server
3 Updating database please retry Database updates only take less than a second so retry.
4 Down for maintenance  
5 Invalid Credentials Ensure you account id and api key is correct.
6 Account on Hold Your API access has been put on hold, probably for misuse of account.
7 Quota Limit Reached, try again later  
8 Invalid Input The IP address you specified was not a valid IPv4 address.
9 Invalid IP Access (ipaddress) You have IP Lock restrictions implemented and the IP address that sent the request is not in the IP Lock list.

 

Example PHP Code:

<?php

$u='GN000000'; //replace with your AccountID
$k='67eb6209d68c7fcee6a4313455d7a652'; //replace with your API key
$ip=$_SERVER['REMOTE_ADDR'];
$result = file_get_contents("http://api.gonew.co.uk/ip2c/ip2c.php?u=$u&k=$k&ip=$ip");
if ($result && strpos($result,"OK:\n")===0) {
	//success
	$bits=explode('|',$result);
	echo("IP: $ip - Country Code: $bits[1]  Country Name: $bits[2]");
} else if ($result) {
	//error reported from server
	echo($result);
} else {
	//Failed to connect to server
	echo("Failed to connect to server");
}

?>