Overview
IPstack is an API service designed for retrieving real-time geolocation and related information from IP addresses. It offers a straightforward REST API that accepts an IP address (IPv4 or IPv6) and returns structured JSON data containing details such as country, city, continent, latitude, longitude, postal code, and time zone. Beyond basic location data, the API also provides information on currency and language associated with the detected location, which can be used for localized user experiences. The service aims to support developers in building applications that require location-aware functionalities without managing extensive IP databases directly.
Developers typically integrate IPstack for use cases that include website personalization, where content or advertisements are dynamically adjusted based on a visitor's geographical origin. For example, an e-commerce site might display prices in the local currency or highlight region-specific promotions. Another common application is in fraud detection, where discrepancies between a user's stated location and their IP-based location can signal suspicious activity. Additionally, IPstack is used for geo-targeting content, ensuring that digital services comply with regional content restrictions or offer relevant localized services.
The API handles both single IP lookups and bulk queries, allowing for efficient processing of multiple addresses. It integrates with various programming languages, with SDKs available for PHP, Python, Ruby, and jQuery to streamline development. The service provides a free tier for initial exploration and smaller projects, supporting up to 10,000 requests per month. For higher volumes, paid plans offer increased request limits and additional features like HTTPS encryption and advanced data fields. The underlying data is updated regularly to maintain accuracy as IP assignments change globally, a critical factor for reliable geolocation services, as detailed in general discussions of IP address lookup reliability on sites like High Scalability's discussion of IP lookup services.
APILayer, part of Idera, Inc., owns IPstack, and the service has been available since 2017. It aims to provide a balance of features, performance, and ease of use for developers needing precise IP-based data for their applications, with a focus on compliance standards like GDPR for data privacy.
Key features
- IP Geolocation API: Provides country, region, city, latitude, longitude, zip code, and time zone data based on an IP address.
- IPv4 and IPv6 Support: Processes both common IP address formats for comprehensive coverage.
- Currency Conversion: Returns the local currency code and symbol for the detected IP location, useful for international pricing.
- Language Conversion: Identifies the primary language associated with the geographic location, aiding in content localization.
- ASN and ISP Data: Offers Autonomous System Number (ASN) and Internet Service Provider (ISP) details for network-level insights.
- Security Module: Provides additional data points such as proxy IP detection, crawler status, and threat levels (available on higher tiers).
- Bulk IP Lookup: Allows querying multiple IP addresses in a single request, reducing API calls and improving efficiency.
- GDPR Compliance: Adheres to General Data Protection Regulation (GDPR) standards for user data handling.
Pricing
IPstack offers a free tier and various paid subscription plans, scaled by monthly request volume and available features. All paid plans include SSL encryption and technical support.
| Plan | Monthly Requests | Price/Month (USD) | Key Features |
|---|---|---|---|
| Free | 10,000 | $0 | Basic IP Geolocation |
| Basic | 50,000 | $9.99 | Basic IP Geolocation, HTTPS Encryption |
| Professional | 250,000 | $49.99 | Basic features + Security Module (proxy/crawler detection) |
| Professional Plus | 1,000,000 | $99.99 | Professional features + ASN & ISP data, unlimited bulk lookups |
| Enterprise | Custom | Custom | All features, dedicated support, higher volumes |
Common integrations
- Website Backend Frameworks: PHP, Python, Ruby, and Node.js applications for server-side IP lookup.
- Front-end Web Applications: jQuery for client-side geolocation (though server-side is generally recommended for accuracy and security).
- CRM Systems: Salesforce or HubSpot, to enrich customer profiles with geographic data for targeted marketing.
- E-commerce Platforms: Shopify or Magento, for displaying localized pricing, currency, or content based on visitor location.
- Fraud Detection Systems: Custom or third-party solutions to flag suspicious logins or transactions based on IP location anomalies.
- Analytics Dashboards: Integrating IP data into tools like Google Analytics or custom dashboards for a deeper understanding of user demographics.
Alternatives
- ip-api.com: Offers similar IP geolocation services with a focus on simplicity and performance.
- Abstract API - IP Geolocation: Provides an IP geolocation API alongside other utility APIs, often with a generous free tier.
- GeoJS: A free IP geolocation API that also delivers client-side JavaScript for easy web integration.
- AWS Route 53 Geolocation Routing: While not a direct API service for lookup, it offers DNS-based geo-targeting for web traffic, a related use case for directing users to specific endpoints based on location.
- Google Maps Geolocation API: Focuses on obtaining location from cell towers and WiFi nodes, complementary to IP-based lookups for more precise mobile device positioning.
Getting started
To begin using the IPstack API, you first need an API access key, which can be obtained by signing up on their IPstack homepage. Once you have your key, you can make a simple HTTP GET request to their API endpoint, providing the IP address you wish to query and your access key. The examples below demonstrate how to perform a basic lookup using Python and the popular requests library.
First, install the requests library if you don't have it:
pip install requests
Then, you can make an API call as shown below:
import requests
ACCESS_KEY = 'YOUR_API_ACCESS_KEY' # Replace with your actual IPstack API key
IP_ADDRESS = '134.201.250.155' # Example IP address for New York City
def get_ip_geolocation(ip_address, access_key):
base_url = f"http://api.ipstack.com/{ip_address}"
params = {
'access_key': access_key
}
try:
response = requests.get(base_url, params=params)
response.raise_for_status() # Raise an exception for HTTP errors
data = response.json()
if data.get('success') is False:
print(f"API Error: {data.get('error', {}).get('info', 'Unknown error')}")
else:
print("IP Geolocation Data:")
print(f" IP: {data.get('ip')}")
print(f" Country: {data.get('country_name')}")
print(f" City: {data.get('city')}")
print(f" Latitude: {data.get('latitude')}")
print(f" Longitude: {data.get('longitude')}")
print(f" Currency: {data.get('currency', {}).get('code', 'N/A')}")
print(f" Language: {data.get('location', {}).get('languages', [{}])[0].get('name', 'N/A')}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
except ValueError:
print("Failed to decode JSON response.")
# Call the function with your key and target IP
get_ip_geolocation(IP_ADDRESS, ACCESS_KEY)
# You can also make a request for the current client's IP address (if not testing locally):
# get_ip_geolocation('check', ACCESS_KEY)
This Python script makes a request to the IPstack API and prints the returned geolocation details. The 'check' endpoint can be used to automatically detect the IP address of the client making the API request. Remember to replace 'YOUR_API_ACCESS_KEY' with your actual access key from your IPstack account dashboard, as detailed in the IPstack API documentation.