Overview
Hirak IP to Country offers a suite of downloadable databases designed for developers and businesses to perform IP geolocation lookups. Unlike real-time API services, Hirak's primary offering involves providing datasets that users integrate directly into their own systems. This approach allows for local, high-speed lookups without dependency on external network requests, which can be beneficial for performance-critical applications or environments with intermittent internet access.
The core products include the IP to Country Database, capable of identifying the country associated with a given IP address; the IP to City Database, offering more granular city-level data; and the IP to ISP Database, which provides details about the Internet Service Provider. These databases are structured for direct integration into various application environments, supporting use cases such as geographic content customization, ad targeting, fraud prevention, and analytics. For example, an e-commerce platform might use the IP to Country database to display prices in the local currency or restrict access to certain products based on the user's country of origin. The developer documentation outlines the integration process for various programming languages and database systems.
The target audience for Hirak IP to Country includes developers and technical buyers who require static, frequently updated geolocation data for internal systems. This model contrasts with API-centric services like ipstack, which provide real-time lookup capabilities through HTTP requests. Hirak's model is suited for scenarios where a self-hosted, performance-optimized solution is preferred, or where data needs to be processed in bulk offline. Updates to the databases are offered via annual subscriptions, ensuring the data remains current. This is important because IP address assignments and geographic locations can change over time, necessitating regular updates for accuracy, as highlighted by other providers like MaxMind GeoIP2.
Key features
- IP to Country Database: Provides mapping of IP addresses to their corresponding countries, suitable for geo-targeting and content localization.
- IP to City Database: Offers more granular geolocation data, including city, region, and postal codes, for more precise demographic targeting.
- IP to ISP Database: Identifies the Internet Service Provider associated with an IP address, useful for network analysis and security applications.
- Offline Lookup Capability: Databases are downloaded and integrated locally, enabling lookups without external API calls and reducing latency.
- Regular Updates: Annual subscriptions are available to ensure the databases remain current with changes in IP address allocations and geographical data.
- GDPR Compliance: Adheres to General Data Protection Regulation (GDPR) standards for data handling and privacy.
Pricing
Hirak IP to Country primarily offers one-time purchases for its database products, with annual subscriptions available for ongoing updates. The pricing varies based on the type and granularity of the database.
| Product | Type | Starting Price (One-time) | Update Frequency |
|---|---|---|---|
| IP to Country Database | Downloadable Database | $499 | Annual Subscription for updates |
| IP to City Database | Downloadable Database | Varies (higher than Country) | Annual Subscription for updates |
| IP to ISP Database | Downloadable Database | Varies (higher than Country) | Annual Subscription for updates |
Pricing as of 2026-05-28. For detailed and up-to-date pricing information, refer to the official Hirak IP to Country pricing page.
Common integrations
Hirak IP to Country databases are designed for direct integration into various application environments and database systems. The integration process typically involves importing the provided data files into a local database or application memory for lookup.
- Custom Applications: Developers can integrate the database into applications built with languages like Python, Java, PHP, or .NET for custom geolocation logic.
- Database Systems: The data can be imported into relational databases (e.g., MySQL, PostgreSQL) or NoSQL databases (e.g., MongoDB) for efficient querying.
- Web Servers: Integration with web server configurations (e.g., Apache, Nginx) for real-time request filtering or content delivery based on IP location.
- CRM/ERP Systems: Enhancing customer data with geographic information for sales and marketing analytics.
- Ad Serving Platforms: Implementing geo-targeting rules within ad delivery systems.
For detailed instructions and sample data, developers can consult the Hirak IP to Country developer resources.
Alternatives
- MaxMind GeoIP: Offers both downloadable databases (GeoIP2) and an API for IP geolocation, providing country, city, and ASN data.
- ipstack: A real-time IP geolocation API that delivers location data (country, city, region, coordinates) and additional information like currency and time zone.
- DB-IP: Provides IP geolocation databases (country, city, region, ISP) and a real-time API, available in various formats for integration.
Getting started
To get started with Hirak IP to Country, the primary step is to download and integrate one of their databases into your application. Below is a conceptual example demonstrating how one might load IP-to-country data into a Python application for local lookups, assuming the database is provided as a CSV or similar flat file format that can be parsed and stored efficiently.
This example assumes you have downloaded the IP to Country database and have access to a file, for instance, ip_country_blocks.csv, which contains IP ranges and corresponding country codes.
import csv
import ipaddress
class IPCountryLookup:
def __init__(self, db_path):
self.ip_ranges = [] # Stores (start_ip_int, end_ip_int, country_code)
self._load_database(db_path)
def _load_database(self, db_path):
with open(db_path, mode='r', encoding='utf-8') as file:
reader = csv.reader(file)
# Assuming CSV format: start_ip_address,end_ip_address,country_code
# Skip header if present
next(reader, None)
for row in reader:
if len(row) == 3:
try:
start_ip = int(ipaddress.ip_address(row[0]))
end_ip = int(ipaddress.ip_address(row[1]))
country_code = row[2]
self.ip_ranges.append((start_ip, end_ip, country_code))
except ValueError as e:
print(f"Skipping invalid row: {row} - {e}")
# Sort IP ranges for efficient binary search
self.ip_ranges.sort(key=lambda x: x[0])
def get_country(self, ip_address_str):
try:
target_ip_int = int(ipaddress.ip_address(ip_address_str))
except ValueError:
return "Invalid IP Address"
# Perform binary search
low, high = 0, len(self.ip_ranges) - 1
while low <= high:
mid = (low + high) // 2
start_ip, end_ip, country_code = self.ip_ranges[mid]
if start_ip <= target_ip_int <= end_ip:
return country_code
elif target_ip_int < start_ip:
high = mid - 1
else:
low = mid + 1
return "Unknown"
# --- Example Usage ---
# Create a dummy CSV file for demonstration
with open('ip_country_blocks.csv', 'w', encoding='utf-8') as f:
f.write("start_ip,end_ip,country_code\n")
f.write("1.0.0.0,1.0.0.255,AU\n")
f.write("8.8.8.0,8.8.8.255,US\n")
f.write("104.16.0.0,104.31.255.255,US\n") # Example for Cloudflare IPs
f.write("185.199.108.0,185.199.111.255,US\n") # Example for GitHub Pages
f.write("203.0.113.0,203.0.113.255,NZ\n")
# Initialize the lookup class with your database file path
ip_lookup = IPCountryLookup('ip_country_blocks.csv')
# Test with various IP addresses
print(f"8.8.8.8 is in: {ip_lookup.get_country('8.8.8.8')}") # Expected: US
print(f"1.0.0.1 is in: {ip_lookup.get_country('1.0.0.1')}") # Expected: AU
print(f"192.168.1.1 is in: {ip_lookup.get_country('192.168.1.1')}") # Expected: Unknown (private IP)
print(f"203.0.113.42 is in: {ip_lookup.get_country('203.0.113.42')}") # Expected: NZ
print(f"104.20.0.1 is in: {ip_lookup.get_country('104.20.0.1')}") # Expected: US (Cloudflare example)
print(f"Invalid IP is in: {ip_lookup.get_country('invalid-ip')}") # Expected: Invalid IP Address
This Python script outlines the common pattern: loading the IP range data, parsing it into an efficient data structure (like a sorted list of tuples), and then implementing a lookup function (e.g., binary search) to find the matching country for a given IP. Developers would adapt this pattern based on their chosen programming language and database technology.