ipTRACKERonline's API Users Guide

ipTRACKERonline API - User Guide

The ipTRACKERonline API allows users to retrieve detailed geolocation data for a given IP address. When accessed via the xml.php endpoint, the API returns data in XML format, providing information such as country, city, latitude, longitude, timezone, and more. If accessed via a standard web request, the data is displayed in an HTML format with a map and visual details.

Rate Limits & Quotas:
- Your API key will have a certain number of queries(credits) allocated depending on what package you purchased.
- Once your API key credits are used up (unless on a monthly unlimited plan), your API key can no longer be used, a new API key is generated for security reasons.
- If an API key is not used for 12 months, it is automatically deleted from the system.

Https API Request Format

Basic http access without an API key (limit to 5 requests per day)

https://www.iptrackeronline.com/?ip_address=IP_ADDRESS_HERE

Basic http access using your API key

(In order to use the xml.php endpoint you will be requred to purchase an API key)

https://www.iptrackeronline.com/?k=ENTER_YOUR_KEY_HERE&ip_address=IP_ADDRESS_HERE

XML API Request Format

Using the xml.php endpoint for API access, simply send a GET or POST request to the following URL:

https://www.iptrackeronline.com/xml.php?k=ENTER_YOUR_KEY_HERE&ip_address=IP_ADDRESS_HERE

Replace ENTER_YOUR_KEY_HERE with your unique API key and IP_ADDRESS_HERE with the IP address you want to look up.

Example Request

https://www.iptrackeronline.com/xml.php?k=12345abcde&ip_address=8.8.8.8

Example Response

<response>
<result>
<ipaddress>8.8.8.8</ipaddress>
<hostname>dns.google</hostname>
<provider>Google LLC</provider>
<country>United States of America</country>
<countrycode>US</countrycode>
<countryflag>Flag</countryflag>
<state>California</state>
<city>Mountain View</city>
<latitude>37.386051</latitude>
<longitude>-122.083847</longitude>
</result>
</response>

Code Snippets

Bash Example

#!/bin/bash

# -----------------------------------------------------------------------------
# Sample Bash Script for using ipTRACKERonline's Geolocation API
# (c) 2024 ipTRACKERonline - For educational purposes only
# -----------------------------------------------------------------------------
# This script demonstrates how to use a Bash script to interact with the 
# ipTRACKERonline Geolocation API to retrieve information about an IP address.
# -----------------------------------------------------------------------------
# 1. Define your API key here
API_KEY="YOUR_API_KEY"

# 2. Prompt the user for an IP address
read -p "Enter the IP address: " IP_ADDRESS

# 3. Construct the API request URL
URL="https://www.iptrackeronline.com/xml.php?k=$API_KEY&ip_address=$IP_ADDRESS"

# 4. Send a request to the API using curl
response=$(curl -s "$URL")

# 5. Check if the response is not empty
if [ -n "$response" ]; then
    # Parse each field using specific XML tags
    ipaddress=$(echo "$response" | grep -oP '(?<=<ipaddress>).*?(?=</ipaddress>)')
    hostname=$(echo "$response" | grep -oP '(?<=<hostname>).*?(?=</hostname>)')
    provider=$(echo "$response" | grep -oP '(?<=<provider>).*?(?=</provider>)')
    country=$(echo "$response" | grep -oP '(?<=<country>).*?(?=</country>)')
    countrycode=$(echo "$response" | grep -oP '(?<=<countrycode>).*?(?=</countrycode>)')
    countryflag=$(echo "$response" | grep -oP '(?<=<countryflag>).*?(?=</countryflag>)')
    state=$(echo "$response" | grep -oP '(?<=<state>).*?(?=</state>)')
    city=$(echo "$response" | grep -oP '(?<=<city>).*?(?=</city>)')
    areacode=$(echo "$response" | grep -oP '(?<=<areacode>).*?(?=</areacode>)')
    postalcode=$(echo "$response" | grep -oP '(?<=<postalcode>).*?(?=</postalcode>)')
    dmacode=$(echo "$response" | grep -oP '(?<=<dmacode>).*?(?=</dmacode>)')
    timezone=$(echo "$response" | grep -oP '(?<=<timezone>).*?(?=</timezone>)')
    gmtoffset=$(echo "$response" | grep -oP '(?<=<gmtoffset>).*?(?=</gmtoffset>)')
    continent=$(echo "$response" | grep -oP '(?<=<continent>).*?(?=</continent>)')
    latitude=$(echo "$response" | grep -oP '(?<=<latitude>).*?(?=</latitude>)')
    longitude=$(echo "$response" | grep -oP '(?<=<longitude>).*?(?=</longitude>)')
    queries=$(echo "$response" | grep -oP '(?<=<queries>).*?(?=</queries>)')
    accuracy=$(echo "$response" | grep -oP '(?<=<accuracy>).*?(?=</accuracy>)')

    # Echo the parsed results
    echo "Ip Address: $ipaddress"
    echo "HostName: $hostname"
    echo "Provider: $provider"
    echo "Country: $country"
    echo "Country Code: $countrycode"
    echo "Country Flag: $countryflag"
    echo "State: $state"
    echo "City: $city"
    echo "Area Code: $areacode"
    echo "Postal Code: $postalcode"
    echo "Dma Code: $dmacode"
    echo "Time Zone: $timezone"
    echo "Gmt Offset: $gmtoffset"
    echo "Continent: $continent"
    echo "Latitude: $latitude"
    echo "Longitude: $longitude"
    echo "Queries: $queries"
    echo "Accuracy: $accuracy"
else
    echo "Error: No response from API. Please check your API key and IP address."
fi

C# Example

// -----------------------------------------------------------------------------
// Sample C# Script for using ipTRACKERonline's Geolocation API
// (c) 2024 ipTRACKERonline - For educational purposes only
// -----------------------------------------------------------------------------
// This script demonstrates how to use a C# program to interact with the 
// ipTRACKERonline Geolocation API to retrieve information about an IP address.
// -----------------------------------------------------------------------------

using System;          // Provides basic functionalities like input/output and types.
using System.Net.Http;  // Allows sending HTTP requests and receiving responses.
using System.Threading.Tasks; // Enables asynchronous programming using async/await.
using System.Xml.Linq;  // Provides XML-related functionalities for parsing XML data.

class Program
{
    // Main entry point of the program
    // 'async Task' is used for asynchronous programming in C#.
    static async Task Main(string[] args)
    {
        // 1. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
        string apiKey = "ENTER_YOUR_KEY_HERE";
        
        // 2. IP address for which we want to retrieve geolocation data
        string ipAddress = "8.8.8.8"; // You can modify this to allow user input or pass as an argument
        
        // 3. Construct the API request URL
        // The URL contains the API key and IP address.
        string url = $"https://www.iptrackeronline.com/xml.php?k={apiKey}&ip_address={ipAddress}";

        // 4. Create an instance of HttpClient to send an HTTP GET request to the API
        // The 'using' statement ensures the HttpClient object is disposed of properly.
        using (HttpClient client = new HttpClient())
        {
            // 5. Send the GET request asynchronously and await the response.
            HttpResponseMessage response = await client.GetAsync(url);

            // 6. Check if the request was successful (i.e., status code 200 OK)
            if (response.IsSuccessStatusCode)
            {
                // 7. Retrieve the body of the response as a string
                string responseBody = await response.Content.ReadAsStringAsync();

                // 8. Parse the XML response using XDocument
                // XDocument is used to load and query the XML data.
                XDocument xml = XDocument.Parse(responseBody);

                // 9. Extract the 'country' element from the XML and print it
                // Assumes the XML structure contains a  element.
                var country = xml.Root.Element("result").Element("country").Value;
                Console.WriteLine($"Country: {country}");

                // 10. (Optional) You can add additional elements to extract here
                // For example:
                // var city = xml.Root.Element("result").Element("city").Value;
                // Console.WriteLine($"City: {city}");
            }
            else
            {
                // 11. If the request was not successful, print an error message
                Console.WriteLine("Error: Unable to fetch data. Please check your API key and IP address.");
            }
        }
    }
}

cUrl Example

# -----------------------------------------------------------------------------
# Sample curl Command for using ipTRACKERonline's Geolocation API
# (c) 2024 ipTRACKERonline - For educational purposes only
# -----------------------------------------------------------------------------
# This curl command demonstrates how to interact with the ipTRACKERonline 
# Geolocation API to retrieve information about a specific IP address.
# 
# Instructions:
# 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
# 2. Modify the 'ip_address' parameter to query any valid IP address of your choice.
# -----------------------------------------------------------------------------

# Example curl command to query geolocation information for an IP address.
# Replace 'ENTER_YOUR_KEY_HERE' with your API key and adjust the IP address as needed.
curl "https://www.iptrackeronline.com/xml.php?k=ENTER_YOUR_KEY_HERE&ip_address=8.8.8.8"

# -----------------------------------------------------------------------------
# How this works:
# - The 'curl' command is used to make an HTTP GET request to the ipTRACKERonline API.
# - The 'k' parameter represents your API key, which must be provided for authentication.
# - The 'ip_address' parameter specifies the IP address for which geolocation information is requested.
# 
# Response:
# - The API will return an XML document containing geolocation details such as the country,
#   city, latitude, longitude, ISP, and more, related to the provided IP address.
# -----------------------------------------------------------------------------

# Sample output:
# 
#   
#     8.8.8.8
#     dns.google
#     Google LLC
#     United States of America
#     US
#     California
#     Mountain View
#     37.386051
#     -122.083847
#     America/New_York
#   
# 
# -----------------------------------------------------------------------------

Go Example

// -----------------------------------------------------------------------------
// Sample Go Program for using ipTRACKERonline's Geolocation API
// (c) 2024 ipTRACKERonline - For educational purposes only
// -----------------------------------------------------------------------------
// This Go program demonstrates how to interact with the ipTRACKERonline 
// Geolocation API to retrieve information about a specific IP address.
//
// Instructions:
// 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
// 2. Modify the 'ipAddress' variable to query any valid IP address of your choice.
// -----------------------------------------------------------------------------

package main

import (
	"encoding/xml"   // For parsing XML response
	"fmt"            // Provides formatted I/O functions
	"io/ioutil"      // For reading HTTP response body
	"net/http"       // For making HTTP GET requests
)

// Struct to hold the result from the API response (only parsing country here)
type Result struct {
	Country string `xml:"country"`  // This maps the 'country' field from the XML response
}

// Struct to hold the entire API response
type Response struct {
	Result Result `xml:"result"`  // This maps the 'result' section of the XML response
}

func main() {
	// 1. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
	apiKey := "ENTER_YOUR_KEY_HERE"
	
	// 2. Define the IP address you want to look up
	ipAddress := "8.8.8.8"  // You can change this to any IP address for testing
	
	// 3. Construct the API request URL
	url := fmt.Sprintf("https://www.iptrackeronline.com/xml.php?k=%s&ip_address=%s", apiKey, ipAddress)

	// 4. Send a GET request to the API using http.Get
	resp, err := http.Get(url)
	if err != nil {
		fmt.Println("Error:", err)  // Print the error if the request fails
		return
	}
	defer resp.Body.Close()  // Ensure the response body is closed after reading

	// 5. Read the response body
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Error reading response:", err)  // Print the error if reading the response fails
		return
	}

	// 6. Parse the XML response
	var response Response
	err = xml.Unmarshal(body, &response)
	if err != nil {
		fmt.Println("Error parsing XML:", err)  // Print the error if parsing the XML fails
		return
	}

	// 7. Output the country field from the parsed response
	fmt.Printf("Country: %s\n", response.Result.Country)

	// 8. (Optional) Add more fields to parse and display if desired
	// For example, you could extract the city or ISP by adding corresponding fields in the Result struct.
}

Java Example

// -----------------------------------------------------------------------------
// Sample Java Program for using ipTRACKERonline's Geolocation API
// (c) 2024 ipTRACKERonline - For educational purposes only
// -----------------------------------------------------------------------------
// This Java program demonstrates how to interact with the ipTRACKERonline 
// Geolocation API to retrieve information about a specific IP address.
//
// Instructions:
// 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
// 2. Modify the 'ipAddress' variable to query any valid IP address of your choice.
// -----------------------------------------------------------------------------

import java.io.*;                       // Provides classes for input and output, including streams and readers.
import java.net.*;                      // Provides classes for networking, including URL and HttpURLConnection.
import javax.xml.parsers.*;             // Provides classes for parsing XML documents.
import org.w3c.dom.*;                   // Provides classes for working with XML nodes.

public class IPTracker {
    public static void main(String[] args) {
        // 1. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
        String apiKey = "ENTER_YOUR_KEY_HERE";
        
        // 2. Define the IP address you want to look up
        String ipAddress = "8.8.8.8";  // You can change this to any IP address for testing
        
        // 3. Construct the API request URL
        String urlString = "https://www.iptrackeronline.com/xml.php?k=" + apiKey + "&ip_address=" + ipAddress;

        try {
            // 4. Create a URL object from the request URL
            URL url = new URL(urlString);
            
            // 5. Open an HTTP connection to the API endpoint
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");  // Set the request method to GET

            // 6. Read the response using BufferedReader and InputStreamReader
            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String inputLine;
            StringBuilder content = new StringBuilder();

            // 7. Read each line from the API response and append it to the StringBuilder
            while ((inputLine = in.readLine()) != null) {
                content.append(inputLine);
            }

            // 8. Close the reader and disconnect the connection
            in.close();
            conn.disconnect();

            // 9. Parse the XML response using DocumentBuilder
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document doc = builder.parse(new ByteArrayInputStream(content.toString().getBytes()));

            // 10. Extract the 'country' element from the XML response
            NodeList countryList = doc.getElementsByTagName("country");
            if (countryList.getLength() > 0) {
                String country = countryList.item(0).getTextContent();
                System.out.println("Country: " + country);  // Output the country value
            }

        } catch (Exception e) {
            // 11. Handle any exceptions that occur during the process
            e.printStackTrace();
        }
    }
}

JavaScript (Node.js with axios) Example

// -----------------------------------------------------------------------------
// Sample Node.js Program for using ipTRACKERonline's Geolocation API with Axios
// (c) 2024 ipTRACKERonline - For educational purposes only
// -----------------------------------------------------------------------------
// This Node.js program demonstrates how to interact with the ipTRACKERonline 
// Geolocation API to retrieve information about a specific IP address using Axios.
//
// Instructions:
// 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
// 2. Modify the 'ipAddress' variable to query any valid IP address of your choice.
// -----------------------------------------------------------------------------

// 1. Import the axios library for making HTTP requests
const axios = require('axios');

// 2. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
const apiKey = 'ENTER_YOUR_KEY_HERE';

// 3. Define the IP address you want to look up
const ipAddress = '8.8.8.8';  // You can change this to any IP address for testing

// 4. Construct the API request URL
const url = `https://www.iptrackeronline.com/xml.php?k=${apiKey}&ip_address=${ipAddress}`;

// 5. Send a GET request to the API using axios
axios.get(url)
  .then(response => {
    // 6. Handle the successful response and output the raw XML response
    console.log(response.data);

    // (Optional) You can parse and extract specific elements here from the XML response
    // For example, you can use xml2js or another XML parser to extract specific fields like 'country', 'city', etc.
  })
  .catch(error => {
    // 7. Handle any errors that may occur during the request
    console.log('Error:', error);
  });

PHP Example


<?php
// -----------------------------------------------------------------------------
// Sample PHP Script for using ipTRACKERonline's Geolocation API
// (c) 2024 ipTRACKERonline - For educational purposes only
// -----------------------------------------------------------------------------
// This PHP script demonstrates how to interact with the ipTRACKERonline 
// Geolocation API to retrieve information about a specific IP address.
//
// Instructions:
// 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
// 2. Modify the 'ip_address' variable to query any valid IP address of your choice.
// -----------------------------------------------------------------------------

// 1. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
$api_key = 'ENTER_YOUR_KEY_HERE';

// 2. Define the IP address you want to look up
$ip_address = '8.8.8.8';  // You can change this to any IP address for testing

// 3. Construct the API request URL
$url = "https://www.iptrackeronline.com/xml.php?k=$api_key&ip_address=$ip_address";

// 4. Use file_get_contents to send the GET request and get the response
$response = file_get_contents($url);

// 5. Check if the response was successfully retrieved
if ($response !== false) {
    // 6. Parse the XML response using SimpleXML
    $xml = simplexml_load_string($response);

    // 7. Output the country field from the parsed XML
    echo "Country: " . $xml->result->country;

    // (Optional) You can extract other fields like city, provider, etc.
    // Example:
    // echo "City: " . $xml->result->city;
} else {
    // 8. Handle the case where the API request fails
    echo "Error: Unable to retrieve data from ipTRACKERonline API.";
}

?>

Python Example (Using requests Library)

# -----------------------------------------------------------------------------
# Sample Python Script for using ipTRACKERonline's Geolocation API (with requests)
# (c) 2024 ipTRACKERonline - For educational purposes only
# -----------------------------------------------------------------------------
# This Python script demonstrates how to interact with the ipTRACKERonline 
# Geolocation API to retrieve information about a specific IP address using the 
# 'requests' library.
#
# Instructions:
# 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
# 2. Modify the 'ip_address' variable to query any valid IP address of your choice.
# -----------------------------------------------------------------------------

# 1. Import the requests library to make HTTP requests
import requests

# 2. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
api_key = 'ENTER_YOUR_KEY_HERE'

# 3. Define the IP address you want to look up
ip_address = '8.8.8.8'  # You can change this to any IP address for testing

# 4. Construct the API request URL
url = f"https://www.iptrackeronline.com/xml.php?k={api_key}&ip_address={ip_address}"

# 5. Send a GET request to the API using requests.get()
response = requests.get(url)

# 6. Check if the request was successful (i.e., HTTP status code 200)
if response.status_code == 200:
    # 7. Access the raw content of the response (in bytes) and decode it to a string
    data = response.content
    print(data.decode())  # Output the API response (XML format)
else:
    # 8. Handle errors, such as when the API request fails (non-200 status codes)
    print("Error accessing the API")

Ruby Example

# -----------------------------------------------------------------------------
# Sample Ruby Script for using ipTRACKERonline's Geolocation API
# (c) 2024 ipTRACKERonline - For educational purposes only
# -----------------------------------------------------------------------------
# This Ruby script demonstrates how to interact with the ipTRACKERonline 
# Geolocation API to retrieve information about a specific IP address using 
# 'Net::HTTP' for the HTTP request and 'Nokogiri' for parsing the XML response.
#
# Instructions:
# 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
# 2. Modify the 'ip_address' variable to query any valid IP address of your choice.
# -----------------------------------------------------------------------------

# 1. Require necessary libraries for HTTP requests and XML parsing
require 'net/http'  # Standard library for HTTP requests
require 'uri'       # Standard library for URI parsing
require 'nokogiri'  # Gem for parsing and working with XML

# 2. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
api_key = 'ENTER_YOUR_KEY_HERE'

# 3. Define the IP address you want to look up
ip_address = '8.8.8.8'  # You can change this to any IP address for testing

# 4. Construct the API request URL
url = URI("https://www.iptrackeronline.com/xml.php?k=#{api_key}&ip_address=#{ip_address}")

# 5. Send a GET request to the API using Net::HTTP.get
response = Net::HTTP.get(url)

# 6. Check if the response is not nil (i.e., successful request)
if response
  # 7. Parse the XML response using Nokogiri
  doc = Nokogiri::XML(response)

  # 8. Extract the 'country' field from the parsed XML
  country = doc.xpath('//result/country').text

  # 9. Output the country value to the console
  puts "Country: #{country}"

  # (Optional) You can extract other fields like 'city', 'provider', etc.
  # Example:
  # city = doc.xpath('//result/city').text
  # puts "City: #{city}"
else
  # 10. Handle the case where the API request fails
  puts "Error: Unable to retrieve data from ipTRACKERonline API."
end

Rust Example

// -----------------------------------------------------------------------------
// Sample Rust Program for using ipTRACKERonline's Geolocation API
// (c) 2024 ipTRACKERonline - For educational purposes only
// -----------------------------------------------------------------------------
// This Rust program demonstrates how to interact with the ipTRACKERonline 
// Geolocation API to retrieve information about a specific IP address using 
// the 'reqwest' library for HTTP requests and 'quick-xml' for parsing the XML response.
//
// Instructions:
// 1. Replace 'ENTER_YOUR_KEY_HERE' with your actual API key obtained from ipTRACKERonline.
// 2. Modify the 'ip_address' variable to query any valid IP address of your choice.
// -----------------------------------------------------------------------------

use reqwest;                          // For making HTTP requests
use std::error::Error;                // For handling errors in the Rust program
use quick_xml::de::from_str;          // For deserializing XML responses into Rust structs
use serde::Deserialize;               // For deriving the Deserialize trait on structs

// 1. Define a struct to map the 'result' section of the API response
#[derive(Debug, Deserialize)]
struct Result {
    country: String,                  // Extract the 'country' field from the XML response
}

// 2. Define a struct to map the entire API response
#[derive(Debug, Deserialize)]
struct Response {
    result: Result,                   // The 'result' contains more details like 'country'
}

#[tokio::main]
async fn main() -> Result<(), Box> {
    // 3. Define your API key here (REPLACE 'ENTER_YOUR_KEY_HERE' with your actual API key)
    let api_key = "ENTER_YOUR_KEY_HERE";

    // 4. Define the IP address you want to look up
    let ip_address = "8.8.8.8";  // You can change this to any IP address for testing

    // 5. Construct the API request URL
    let url = format!(
        "https://www.iptrackeronline.com/xml.php?k={}&ip_address={}",
        api_key, ip_address
    );

    // 6. Send a GET request to the API using reqwest
    let response = reqwest::get(&url).await?.text().await?;

    // 7. Parse the XML response using quick_xml
    let parsed: Response = from_str(&response)?;

    // 8. Output the 'country' field from the parsed XML response
    println!("Country: {}", parsed.result.country);

    // 9. Handle the successful completion of the program
    Ok(())
}