API Services

Developer documentation and integration guides

🔌 InfoSniper API Services

Integrate powerful IP geolocation services into your applications with our XML and JSON APIs.

📋 API Overview

InfoSniper offers two API endpoints for accessing IP geolocation data:

📄 XML API

Endpoint: xml.php

Returns structured XML data - perfect for legacy systems and SOAP integrations.

🔧 JSON API

Endpoint: json.php

Returns clean JSON data - ideal for modern web applications and REST APIs.

🔑 Authentication Required

Both APIs require a valid API key. Get your API key here to start making requests.

📄 XML API Documentation
Endpoint Parameters
Parameter Required Description
k Required Your API key
ip_address Required IP address to lookup (IPv4 or IPv6)
Example Request
curl "https://www.infosniper.net/xml.php?k=YOUR_API_KEY&ip_address=8.8.8.8"
Example Response


  
    8.8.8.8
    dns.google
    Google LLC
    United States
    US
    https://www.infosniper.net/country_flags/us.gif
    CA
    Mountain View
    650
    94043
    807
    America/Los_Angeles
    -08:00
    37.4056
    -122.0775
    999
    5
  
🔧 JSON API Documentation
Endpoint Parameters
Parameter Required Description
k Required Your API key
ip_address Required IP address to lookup (IPv4 or IPv6)
Example Request
curl "https://www.infosniper.net/json.php?k=YOUR_API_KEY&ip_address=8.8.8.8"
Example Response
{
  "ipaddress": "8.8.8.8",
  "hostname": "dns.google",
  "provider": "Google LLC",
  "country": "United States",
  "countrycode": "US",
  "countryflag": "https://www.infosniper.net/country_flags/us.gif",
  "state": "CA",
  "city": "Mountain View",
  "areacode": "650",
  "postalcode": "94043",
  "dmacode": "807",
  "timezone": "America/Los_Angeles",
  "gmtoffset": "-08:00",
  "latitude": "37.4056",
  "longitude": "-122.0775",
  "queries": "999",
  "accuracy": "5"
}
💻 Code Examples
🐘 PHP Examples
XML API with PHP
result[0]->ipaddress . "\n";
echo "Country: " . $xml->result[0]->country . "\n";
echo "City: " . $xml->result[0]->city . "\n";
echo "Latitude: " . $xml->result[0]->latitude . "\n";
echo "Longitude: " . $xml->result[0]->longitude . "\n";
?>
JSON API with PHP
🐍 Python Examples
JSON API with Python
import requests
import json

# JSON API Example
api_key = "YOUR_API_KEY"
ip_address = "8.8.8.8"

url = f"https://www.infosniper.net/json.php?k={api_key}&ip_address={ip_address}"
response = requests.get(url)

if response.status_code == 200:
    data = response.json()
    
    print(f"IP: {data['ipaddress']}")
    print(f"Country: {data['country']}")
    print(f"City: {data['city']}")
    print(f"Latitude: {data['latitude']}")
    print(f"Longitude: {data['longitude']}")
else:
    print(f"Error: {response.status_code}")
🌐 JavaScript Examples
JSON API with JavaScript (Fetch)
// JSON API Example with Fetch
const apiKey = "YOUR_API_KEY";
const ipAddress = "8.8.8.8";

const url = `https://www.infosniper.net/json.php?k=${apiKey}&ip_address=${ipAddress}`;

fetch(url)
  .then(response => response.json())
  .then(data => {
    console.log("IP:", data.ipaddress);
    console.log("Country:", data.country);
    console.log("City:", data.city);
    console.log("Latitude:", data.latitude);
    console.log("Longitude:", data.longitude);
  })
  .catch(error => {
    console.error("Error:", error);
  });
JSON API with Node.js
// JSON API Example with Node.js
const https = require("https");

const apiKey = "YOUR_API_KEY";
const ipAddress = "8.8.8.8";

const url = `https://www.infosniper.net/json.php?k=${apiKey}&ip_address=${ipAddress}`;

https.get(url, (response) => {
  let data = "";

  response.on("data", (chunk) => {
    data += chunk;
  });

  response.on("end", () => {
    const result = JSON.parse(data);
    
    console.log("IP:", result.ipaddress);
    console.log("Country:", result.country);
    console.log("City:", result.city);
    console.log("Latitude:", result.latitude);
    console.log("Longitude:", result.longitude);
  });
}).on("error", (error) => {
  console.error("Error:", error);
});
🔧 cURL Examples
Using cURL command line
# JSON API with cURL
curl -s "https://www.infosniper.net/json.php?k=YOUR_API_KEY&ip_address=8.8.8.8" | jq .

# XML API with cURL
curl -s "https://www.infosniper.net/xml.php?k=YOUR_API_KEY&ip_address=8.8.8.8"

# POST request example
curl -X POST "https://www.infosniper.net/json.php" \
     -d "k=YOUR_API_KEY" \
     -d "ip_address=8.8.8.8"
📊 Response Fields
Field Type Description Example
ipaddress String The queried IP address 8.8.8.8
hostname String Reverse DNS hostname dns.google
provider String Internet Service Provider Google LLC
country String Country name United States
countrycode String 2-letter country code US
countryflag String URL to country flag image https://www.infosniper.net/country_flags/us.gif
state String State/Province code CA
city String City name Mountain View
areacode String Phone area code 650
postalcode String ZIP/Postal code 94043
dmacode String DMA/Metro code 807
timezone String Timezone identifier America/Los_Angeles
gmtoffset String GMT offset -08:00
latitude String Latitude coordinate 37.4056
longitude String Longitude coordinate -122.0775
queries String Remaining API queries 999
accuracy String Accuracy radius in miles 5
⚠️ Error Handling
Common Error Responses
Invalid API Key

When an invalid or missing API key is provided:

{
  "ipaddress": "Not a valid InfoSniper key",
  "hostname": "Not a valid InfoSniper key",
  "provider": "Not a valid InfoSniper key",
  ...
}
Quota Exceeded

When your API quota has been exceeded:

{
  "ipaddress": "8.8.8.8",
  "hostname": "Quota exceeded",
  "provider": "Quota exceeded",
  ...
}
Invalid IP Address

When an invalid IP address is provided:

{
  "ipaddress": "Invalid-IP-Address",
  "hostname": "Invalid-IP-Address",
  "provider": "Invalid-IP-Address",
  ...
}
✅ Best Practices
  • 🔐 Secure your API key: Never expose your API key in client-side code or public repositories
  • Cache responses: Cache geolocation data to reduce API calls and improve performance
  • 🚦 Handle rate limits: Implement proper error handling for quota exceeded responses
  • Validate IP addresses: Always validate IP addresses before making API calls
  • 🌐 Use HTTPS: Always use HTTPS endpoints for secure data transmission
  • 📊 Monitor usage: Keep track of your API usage to avoid unexpected quota limits
  • 🔄 Implement retries: Add retry logic for temporary network failures
🚀 Getting Started
Ready to start?
  1. Get your API key by signing up for a premium account
  2. Choose between XML or JSON endpoints based on your needs
  3. Implement error handling for robust applications
  4. Start making API calls and building amazing applications!