Overview
IP 2 Country offers services for converting IP addresses into country-specific geographical information. Established in 2005, the platform provides two primary products: an IP Geolocation API and an IP Geolocation Database. The API allows developers to make real-time HTTP requests to obtain country data for a given IP address, while the database product offers a downloadable dataset for offline lookups and bulk processing.
This service is designed for applications requiring country-level geographical data without the need for more granular city or regional information. Common use cases include identifying the country of origin for website visitors to deliver localized content, such as displaying region-specific pricing or language variants. For example, an e-commerce platform might use IP 2 Country to automatically display prices in USD for visitors from the United States and EUR for visitors from European countries. Another application is geotargeting advertising campaigns, where advertisers can ensure their ads are shown only to users within specific countries, optimizing campaign relevance and spend.
In the realm of security and fraud detection, IP 2 Country can contribute to identifying suspicious activity by flagging requests originating from countries known for higher rates of fraudulent transactions. For instance, a payment gateway could compare the IP address's country with the billing address country to detect potential discrepancies. Additionally, digital rights management and content licensing often rely on country-level IP blocking or access restrictions, for which this service provides the necessary data. The API's simplicity and the direct nature of its data output make it suitable for developers looking to integrate basic IP-to-country mapping capabilities efficiently into web applications, mobile services, or backend systems. Developers can consult the IP 2 Country API documentation for specific integration details.
While IP 2 Country focuses on country-level data, alternatives like MaxMind GeoIP2 offers more granular geolocation data, including city and ISP information, which may be necessary for applications requiring finer-grained location awareness. Developers should evaluate their specific data requirements to determine the appropriate level of detail needed for their application, balancing precision with API call overheads or database size considerations.
Key features
- IP Geolocation API: Provides a RESTful interface for real-time lookups of IP addresses to their corresponding country names and codes.
- IP Geolocation Database: Offers a downloadable database containing IP ranges and their associated country information, suitable for offline use or bulk processing.
- Country Code and Name: Returns ISO 3166-1 alpha-2 country codes and full country names for identified IP addresses.
- IPv4 and IPv6 Support: Compatible with both IPv4 and IPv6 address formats for comprehensive coverage.
- High Availability: Designed for consistent access to geolocation data for critical applications.
- Multiple Data Formats: API responses are available in JSON format, facilitating parsing and integration into various programming environments.
Pricing
IP 2 Country offers a free tier and various paid plans for both its API and database products as of May 2026. Specific details are available on the IP 2 Country pricing page.
| Product/Plan | Description | Price (as of May 2026) |
|---|---|---|
| Free API Tier | Up to 1,000 daily queries | Free |
| API Basic Plan | 50,000 daily queries | $29/month |
| API Pro Plan | Higher daily query limits | Contact for pricing |
| Geolocation Database | One-time purchase or subscription for updates; pricing varies by data fields and update frequency | Contact for pricing |
Common integrations
IP 2 Country's straightforward REST API facilitates integration into various systems and workflows:
- Web Servers and Backend Applications: Integrate into Node.js, Python, PHP, Java, or Ruby web applications to perform real-time IP lookups for user requests.
- Content Delivery Networks (CDNs): Enhance content localization and geotargeting rules within CDN configurations by using IP 2 Country data.
- Marketing Automation Platforms: Use country data to segment audiences and personalize messaging based on geographical location.
- E-commerce Platforms: Implement country-specific pricing, shipping options, or tax calculations.
- Analytics Dashboards: Enrich website traffic data with country information to gain geographical insights into user behavior.
Alternatives
- MaxMind GeoIP2: A comprehensive geolocation service offering more detailed data including city, postal code, and ISP information.
- Abstract API IP Geolocation: Provides a range of IP data points, often including city, region, and ISP data, in addition to country.
- ipstack: Offers real-time IP to location lookups with support for various data points like country, city, and currency.
Getting started
To get started with the IP 2 Country API, you typically make an HTTP GET request to its API endpoint, including the IP address you wish to query and your API key. Here's a basic example using curl:
curl "https://api.ip2country.com/v1?key=YOUR_API_KEY&ip=8.8.8.8"
Replace YOUR_API_KEY with your actual API key obtained after signing up on the IP 2 Country website, and 8.8.8.8 with the IP address you want to geolocate. The API will return a JSON response containing the country information for that IP address.
A typical JSON response for an IP address might look like this:
{
"countryCode": "US",
"countryName": "United States"
}
For programmatic access, you would use an HTTP client library in your preferred programming language. Below is a Python example demonstrating how to make an API call and parse the JSON response:
import requests
import json
api_key = "YOUR_API_KEY"
ip_address = "8.8.8.8"
api_url = f"https://api.ip2country.com/v1?key={api_key}&ip={ip_address}"
try:
response = requests.get(api_url)
response.raise_for_status() # Raise an exception for HTTP errors
data = response.json()
if data and "countryName" in data:
print(f"IP: {ip_address}")
print(f"Country Code: {data['countryCode']}")
print(f"Country Name: {data['countryName']}")
else:
print(f"Could not retrieve country data for IP: {ip_address}")
print(f"API response: {data}")
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}")
except requests.exceptions.ConnectionError as conn_err:
print(f"Connection error occurred: {conn_err}")
except requests.exceptions.Timeout as timeout_err:
print(f"Timeout error occurred: {timeout_err}")
except requests.exceptions.RequestException as req_err:
print(f"An unexpected error occurred: {req_err}")
except json.JSONDecodeError:
print(f"Failed to decode JSON from response: {response.text}")
This Python script sends a GET request to the IP 2 Country API, prints the country code and name, and includes basic error handling. Developers should refer to the IP 2 Country developer documentation for comprehensive details on all available parameters and error codes.