Single Request API.

Developers that want to create applications that may query IP-API should refer to this documentation.

You can use our data directly from a user's browser or from your server. We serve our data in numerous formats over HTTP using a straightforward URL-based interface.

The API base path is
https://pro.ipapi.org/api_json/one.php?key={your key}&ip={ip address}

{ip address} can be a single IPv4/IPv6 address or a domain name. If you don't supply a query the current IP address will be used.

 

Response Format:


{
    "as": "AS9009 M247 Europe SRL",
    "asname": "M247",
    "callingCode": "40",
    "city": "Bucharest",
    "continent": "Europe",
    "country": "Romania",
    "countryCode": "RO",
    "countryCode3": "ROU",
    "currency": "RON",
    "currentTime": "2024-08-27T23:55:04+03:00",
    "district": "",
    "hosting": true,
    "isp": "M247 Europe SRL",
    "lat": 44.4268,
    "lon": 26.1025,
    "mobile": false,
    "offset": 10800,
    "org": "M247 Europe SRL",
    "proxy": true,
    "region": "B",
    "regionName": "Bucure\u0219ti",
    "reverse": "s10.evio.ro",
    "status": "success",
    "timezone": "Europe\/Bucharest",
    "zip": "052829"
}

If you don't require all the returned fields, use the GET parameter fields to specify which data should be returned.
Separate the fields by comma (fields=country,city)

Example

http(s)://pro.ipapi.org/api_json/one.php?key={your key}&ip={ip address}&fields=region,regionName,city,zip,lat,lon,timezone,isp,org,as,query,status,message,country,countryCode

 

A PHP Code Example

 
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://pro.ipapi.org/api_json/one.php?key=123abc&ip=192.168.1.1',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

A C# Code Example

 
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://pro.ipapi.org/api_json/one.php?key=123abc&ip=192.168.1.1");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

A JAVA Code Example

 
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://pro.ipapi.org/api_json/one.php?key=123abc&ip=192.168.1.1")
  .method("GET", body)
  .build();
Response response = client.newCall(request).execute();

Batch Request API

This is also sililar to our single request api. The only difference is that you can request upto 100 records in one query.:

    The API path is
    https://pro.ipapi.org/api_json/batch.php?key={your key}&ips={ip address1},{ip address2},{ip address3}

    Response Format:

    
    [
        {
            "as": "AS4785 xTom",
            "city": "Osaka",
            "country": "Japan",
            "countryCode": "JP",
            "isp": "xTom Limited",
            "lat": 34.6937,
            "lon": 135.5022,
            "org": "",
            "query": "45.14.71.22",
            "region": "27",
            "regionName": "\u014csaka",
            "status": "success",
            "timezone": "Asia\/Tokyo",
            "zip": ""
        },
        {
            "as": "AS4785 xTom",
            "city": "Osaka",
            "country": "Japan",
            "countryCode": "JP",
            "isp": "xTom Limited",
            "lat": 34.6937,
            "lon": 135.5022,
            "org": "",
            "query": "45.14.71.23",
            "region": "27",
            "regionName": "\u014csaka",
            "status": "success",
            "timezone": "Asia\/Tokyo",
            "zip": ""
        }
    ]
    
    
    A PHP Code Example
     
    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => 'https://pro.ipapi.org/api_json/batch.php?key={your key}&ips={ip address1},{ip address2},{ip address3}',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'GET',
    ));
    
    $response = curl_exec($curl);
    
    curl_close($curl);
    echo $response;
    

    A C# Code Example

     
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, "https://pro.ipapi.org/api_json/batch.php?key={your key}&ips={ip address1},{ip address2}");
    var response = await client.SendAsync(request);
    response.EnsureSuccessStatusCode();
    Console.WriteLine(await response.Content.ReadAsStringAsync());
    

    A JAVA Code Example

     
    OkHttpClient client = new OkHttpClient().newBuilder()
      .build();
    MediaType mediaType = MediaType.parse("text/plain");
    RequestBody body = RequestBody.create(mediaType, "");
    Request request = new Request.Builder()
      .url("https://pro.ipapi.org/api_json/batch.php?key=123abc&ips={ip address1},{ip address2}")
      .method("GET", body)
      .build();
    Response response = client.newCall(request).execute();
    

    Browser Agent to Device Details API

    This is also a simple http api. We have tried to keep all simple to minimise the setup time.

    The API path is
    https://pro.ipapi.org/api_json/device.php?key={your key}&ua={user agent}

    Response Format:

    
     Array
    (
        [os_type] => desktop
        [os_family] => windows
        [os_name] => Windows
        [os_version] => 7
        [os_title] => Windows 7
        [device_type] => desktop
        [browser_name] => Iron
        [browser_version] => 80
        [browser_title] => Iron 80
        [browser_chrome_original] => 0
        [browser_firefox_original] => 0
        [browser_safari_original] => 0
        [browser_chromium_version] => 80
        [browser_gecko_version] => 0
        [browser_webkit_version] => 0
        [browser_android_webview] => 0
        [browser_ios_webview] => 0
        [browser_desktop_mode] => 0
        [64bits_mode] => 1
    )