0151 355 4555



Identifies a country from a customer's IP address. Both IPv4 and IPv6 addresses are supported.

The details of the detected country are provided in the returned CountryDetectionOutput structure. If no country could be identified, the country name and ISO code are both set to "Unknown".

If the ipAddress parameter is left blank, the IP address that the request is being made from will be used. This is particularly useful when integrating the service into a web page via Javascript, at which point the public IP address is not known to the calling code but will be determined automatically by our service.

View all Country Detection methods

Code Samples

<!-- Import the Integr8 Ajax API -->
<!-- NOTE: Get your own API key to use in the following script tag from: -->
<!-- http://www.data-8.co.uk/integr8/Admin/Ajax.aspx -->
<script src="https://webservices.data-8.co.uk/Javascript/Loader.ashx?key=your-api-key" type="text/javascript">

<script type="text/javascript">

function loadIntegr8() {
  // Load the CountryDetection Integr8 service

function IPAddressToCountrySimple(ipAddress) {
  /// <param name="ipAddress">string</param>
  var countrydetection = new data8.countrydetection();

function showIPAddressToCountrySimpleResult(result) {
  // Check that the call succeeded, and show the error message if there was a problem.
  if (!result.Status.Success) {
    alert('Error: ' + result.Status.ErrorMessage);
  else {
    // TODO: Process method results here.
    // Results can be extracted from the following fields:
    // result.CountryName
    //   Contains the ISO standard name of the detected country
    // result.CountryISO
    //   Contains the 2-character ISO code of the detected country
    // result.IDC
    //   Contains the international telephone dialling code of the detected country
    // result.CCTLD
    //   Contains the country-code top level domain name of the detected country