IP Geolocation API Documentation

XML & JSON endpoints for professional IP geolocation services

📋 API Overview

InfoSniper provides professional IP geolocation services through both XML and JSON REST APIs. Get detailed location data for any IP address worldwide.

Key Features:
  • Both XML and JSON response formats
  • GET and POST request methods
  • Real-time IP geolocation data
  • IPv4 and IPv6 support
  • Detailed location information
  • ISP and organization data
  • Timezone and geographic coordinates
Use Cases:
  • Fraud detection and prevention
  • Content personalization
  • Geographic access control
  • Analytics and visitor tracking
  • Compliance and regulatory needs
  • Marketing and targeting
  • Security monitoring
Base URLs:
XML Endpoint: https://www.infosniper.net/xml.php
JSON Endpoint: https://www.infosniper.net/json.php

🔐 Authentication

All API requests require a valid API key. InfoSniper uses key-based authentication to track usage and ensure service quality.

Obtaining an API Key:
  1. Visit our pricing page to select a plan
  2. Complete the purchase process
  3. Your API key will be provided via email
  4. Use the key in all API requests
Key Types:
Type Description Limits
Standard Keys Pay-per-query model with prepaid credits Based on purchased credits
Monthly Subscription Unlimited queries for monthly subscribers Unlimited queries
Important: Keep your API key secure. Do not share it publicly or commit it to version control systems.

🌐 API Endpoints

Available Endpoints:
XML API

Endpoint: /xml.php

Methods: GET, POST

Response: XML format

JSON API

Endpoint: /json.php

Methods: GET, POST

Response: JSON format

Tip: Both endpoints provide identical data. Choose based on your application's preferred data format.

⚙️ Request Parameters

Required Parameters:
Parameter Type Description Example
k string Your API key for authentication YOUR_API_KEY
ip_address string The IP address to lookup (IPv4 or IPv6) 8.8.8.8
Example Requests:
GET Request:
https://www.infosniper.net/xml.php?k=YOUR_API_KEY&ip_address=8.8.8.8
POST Request:
curl -X POST https://www.infosniper.net/json.php \
  -d "k=YOUR_API_KEY" \
  -d "ip_address=8.8.8.8"

📄 Response Format

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 ISP or organization name Google LLC
country string Country name United States
countrycode string Two-letter country code US
countryflag string URL to country flag image https://www.infosniperpro.com/country_flags/us.gif
state string State/region code CA
city string City name Mountain View
areacode string Telephone area code 650
postalcode string Postal/ZIP code 94043
dmacode string International dialing code +1
timezone string Timezone identifier America/Los_Angeles
gmtoffset string GMT offset -08:00
continent string Continent name North America
latitude float Geographic latitude 37.4056
longitude float Geographic longitude -122.0775
queries integer Remaining API queries 9999
accuracy integer Accuracy radius in miles 0
Sample XML Response:
<?xml version="1.0" encoding="UTF-8"?>
<results>
  <result>
    <ipaddress>8.8.8.8</ipaddress>
    <hostname>dns.google</hostname>
    <provider>Google LLC</provider>
    <country>United States</country>
    <countrycode>US</countrycode>
    <countryflag>https://www.infosniperpro.com/country_flags/us.gif</countryflag>
    <state>CA</state>
    <city>Mountain View</city>
    <areacode>650</areacode>
    <postalcode>94043</postalcode>
    <dmacode>+1</dmacode>
    <timezone>America/Los_Angeles</timezone>
    <gmtoffset>-08:00</gmtoffset>
    <continent>North America</continent>
    <latitude>37.4056</latitude>
    <longitude>-122.0775</longitude>
    <queries>9999</queries>
    <accuracy>0</accuracy>
  </result>
</results>
Sample JSON Response:
{
  "result": {
    "ipaddress": "8.8.8.8",
    "hostname": "dns.google",
    "provider": "Google LLC",
    "country": "United States",
    "countrycode": "US",
    "countryflag": "https://www.infosniperpro.com/country_flags/us.gif",
    "state": "CA",
    "city": "Mountain View",
    "areacode": "650",
    "postalcode": "94043",
    "dmacode": "+1",
    "timezone": "America/Los_Angeles",
    "gmtoffset": "-08:00",
    "continent": "North America",
    "latitude": "37.4056",
    "longitude": "-122.0775",
    "queries": 9999,
    "accuracy": 0
  }
}

💻 Code Examples

PHP Example (JSON):
<?php
// InfoSniper API - PHP Example
$api_key = "YOUR_API_KEY";
$ip_address = "8.8.8.8";

// Using cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.infosniper.net/json.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
    'k' => $api_key,
    'ip_address' => $ip_address
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);

// Access the data
echo "Location: " . $data['result']['city'] . ", " . $data['result']['country'];
echo "ISP: " . $data['result']['provider'];
?>
Python Example (JSON):
import requests

# InfoSniper API - Python Example
api_key = "YOUR_API_KEY"
ip_address = "8.8.8.8"

# Make request
response = requests.post(
    "https://www.infosniper.net/json.php",
    data={
        "k": api_key,
        "ip_address": ip_address
    }
)

data = response.json()

# Access the data
print(f"Location: {data['result']['city']}, {data['result']['country']}")
print(f"ISP: {data['result']['provider']}")
print(f"Coordinates: {data['result']['latitude']}, {data['result']['longitude']}")
JavaScript Example (JSON):
// InfoSniper API - JavaScript Example
const apiKey = "YOUR_API_KEY";
const ipAddress = "8.8.8.8";

// Using Fetch API
const formData = new FormData();
formData.append("k", apiKey);
formData.append("ip_address", ipAddress);

fetch("https://www.infosniper.net/json.php", {
    method: "POST",
    body: formData
})
.then(response => response.json())
.then(data => {
    console.log(`Location: ${data.result.city}, ${data.result.country}`);
    console.log(`ISP: ${data.result.provider}`);
    console.log(`Timezone: ${data.result.timezone}`);
})
.catch(error => console.error("Error:", error));
cURL Example (XML):
# GET request
curl "https://www.infosniper.net/xml.php?k=YOUR_API_KEY&ip_address=8.8.8.8"

# POST request
curl -X POST https://www.infosniper.net/xml.php \
  -d "k=YOUR_API_KEY" \
  -d "ip_address=8.8.8.8"

⚠️ Error Handling

Common Error Responses:
Error HTTP Status Response Cause
Missing Parameters 400 Bad Request {"error": "A valid key is required to use this endpoint"} Missing k or ip_address parameter
Invalid API Key 200 OK All fields return "Not a valid infosniperPRO key" Invalid or expired API key
Quota Exceeded 200 OK All fields return "Quota exceeded" API key credits exhausted
Invalid IP Address 200 OK All fields return "Invalid-IP-Address" Malformed or reserved IP address
Best Practices:
  • Always check for error responses before processing data
  • Implement retry logic for network failures
  • Monitor your remaining queries to avoid quota exceeded errors
  • Validate IP addresses before sending requests
  • Log errors for debugging and monitoring
IP Validation Notes:

The API automatically rejects:

  • Private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
  • Reserved IP addresses (0.0.0.0/8, 127.0.0.0/8, etc.)
  • Malformed IP addresses
  • Domain names (use the domain parameter on the main site instead)

❓ Frequently Asked Questions

Both endpoints provide identical data. The only difference is the response format. Choose XML if your application prefers XML parsing, or JSON for modern web applications. JSON responses are typically smaller and faster to parse.

IP geolocation accuracy varies by location. Country-level accuracy is typically 95-99%, while city-level accuracy ranges from 55-80% depending on the region and IP address type. Mobile and residential IPs may have lower accuracy than business IPs.

There are no rate limits in terms of requests per second. Your limit is based on your API key type: standard keys have a prepaid query limit, while monthly subscribers enjoy unlimited queries. The API responds with your remaining queries in each response.

The API endpoints only accept IP addresses. To lookup a domain name, you need to first resolve it to an IP address using DNS, then query our API with that IP. Alternatively, use our web interface at infosniper.net which accepts domain names directly.

Each API response includes a "queries" field showing your remaining credits. For standard keys, this decreases with each request. Monthly subscribers will see "Unlimited" or a high number. Monitor this field to track your usage and plan for credit purchases.

While both HTTP and HTTPS are supported, we strongly recommend using HTTPS for all API requests to ensure your API key and data remain secure during transmission. All examples in this documentation use HTTPS.

InfoSniper does not have a traditional user login system or account dashboard. This is by design for enhanced security. Your API key is your only authentication method. When your credits are exhausted, API keys are not renewed - instead, you simply purchase a new key with fresh credits. This approach eliminates the security risks associated with user accounts, passwords, and stored personal information. To purchase additional credits or a new API key, visit our pricing page.

💡 Integration Best Practices

Performance Optimization:
  • Caching: Cache geolocation results for repeated IP lookups to reduce API calls
  • Batch Processing: Group IP lookups and process them efficiently
  • Error Handling: Implement proper error handling and retry logic
  • Monitoring: Track API usage and response times
Security Recommendations:
  • Store API keys in environment variables, not in code
  • Use HTTPS for all API requests
  • Implement request validation on your server
  • Monitor for unusual usage patterns
  • Rotate API keys periodically
Common Implementation Patterns:
Visitor Tracking:

Capture visitor IPs and lookup their location for analytics and personalization.

Fraud Detection:

Verify user locations against their claimed locations for security.

Content Localization:

Serve region-specific content based on visitor location.

Access Control:

Implement geographic restrictions for compliance or licensing.

📚 Support & Resources

Contact Support

Need help with integration or have questions about our API?

Contact Us
Pro Tip: Start with a small credit package to test the API integration, then upgrade to a monthly subscription for production use with unlimited queries.