Every app that deals with users eventually needs to know where they are. Whether you're personalizing content, blocking suspicious traffic, or logging analytics — IP geolocation is essential.
Most geolocation APIs require signup, API keys, and credit cards. IP-API gives you all of this for free — no key, no signup, no limits for non-commercial use.
What You Get
One HTTP request returns:
- Country, region, city, zip code
- Latitude and longitude
- Timezone
- ISP name and organization
- AS number
Try It Right Now
curl http://ip-api.com/json/8.8.8.8
Response:
{
"status": "success",
"country": "United States",
"regionName": "Virginia",
"city": "Ashburn",
"lat": 39.03,
"lon": -77.5,
"timezone": "America/New_York",
"isp": "Google LLC",
"org": "Google Public DNS",
"query": "8.8.8.8"
}
That's Google's public DNS server — located in Ashburn, Virginia.
Python Example: Geolocate Any IP
import requests
def geolocate(ip):
response = requests.get(f"http://ip-api.com/json/{ip}")
data = response.json()
if data["status"] == "success":
return {
"ip": ip,
"location": f"{data['city']}, {data['regionName']}, {data['country']}",
"coordinates": f"{data['lat']}, {data['lon']}",
"isp": data["isp"],
"timezone": data["timezone"]
}
return {"error": data.get("message", "Unknown error")}
# Try it
result = geolocate("1.1.1.1")
print(result)
# {'ip': '1.1.1.1', 'location': 'Los Angeles, California, United States', ...}
JavaScript (Node.js) Example
async function geolocate(ip) {
const res = await fetch(`http://ip-api.com/json/${ip}`);
const data = await res.json();
if (data.status === "success") {
console.log(`${ip} is in ${data.city}, ${data.country}`);
console.log(`ISP: ${data.isp}`);
console.log(`Coordinates: ${data.lat}, ${data.lon}`);
}
}
geolocate("8.8.8.8");
// 8.8.8.8 is in Ashburn, United States
// ISP: Google LLC
// Coordinates: 39.03, -77.5
Batch Lookup (Up to 100 IPs)
Need to check multiple IPs at once? IP-API supports batch requests:
import requests
ips = ["8.8.8.8", "1.1.1.1", "208.67.222.222"]
response = requests.post(
"http://ip-api.com/batch",
json=ips
)
for result in response.json():
print(f"{result['query']}: {result['city']}, {result['country']} ({result['isp']})")
# 8.8.8.8: Ashburn, United States (Google LLC)
# 1.1.1.1: Los Angeles, United States (Cloudflare, Inc.)
# 208.67.222.222: San Francisco, United States (Cisco OpenDNS, LLC)
Real-World Use Cases
1. Security monitoring — A startup I worked with used IP-API to flag login attempts from unexpected countries. If a user usually logs in from Germany but suddenly appears from Nigeria, that's a red flag.
2. Content personalization — Show currency, language, or shipping options based on visitor location without asking them.
3. Analytics dashboards — Map your API traffic geographically. Know which regions use your service most.
4. Fraud detection — Cross-reference IP geolocation with billing address. Mismatches often indicate fraud.
Rate Limits & Pro Plan
| Feature | Free | Pro ($12.99/mo) |
|---|---|---|
| Rate limit | 45 req/min | Unlimited |
| HTTPS | No | Yes |
| API key | Not needed | Provided |
| Commercial use | No | Yes |
| Batch requests | 100 IPs | 1000 IPs |
For development, testing, and personal projects — the free tier is more than enough.
Compared to Alternatives
| Service | Free Tier | Key Required | HTTPS Free |
|---|---|---|---|
| IP-API | 45 req/min | No | No |
| ipinfo.io | 50K/month | Yes | Yes |
| ipstack | 100/month | Yes | No |
| ipgeolocation.io | 30K/month | Yes | Yes |
| ip-api.com Pro | Unlimited | Yes | Yes |
IP-API wins on simplicity: no signup, no key, just curl and go.
Quick Tips
- Use fields parameter to get only what you need:
curl "http://ip-api.com/json/8.8.8.8?fields=country,city,lat,lon"
- Check your own IP:
curl http://ip-api.com/json/
- Get CSV format for scripts:
curl http://ip-api.com/csv/8.8.8.8
More Free APIs (No Key Required)
- Open-Meteo: Free Weather API — Get forecasts and historical weather data for any location
- ExchangeRate-API: Free Currency Rates — Convert between 160+ currencies instantly
Combine all three: detect location with IP-API → show local weather with Open-Meteo → display prices in local currency with ExchangeRate-API. Zero API keys needed.
Need to process thousands of IPs for security research or analytics? I've built production-grade data extraction tools that handle IP enrichment at scale — no rate limits, no bans.
Need a custom geolocation pipeline? Email me at spinov001@gmail.com
Have you used IP-API in a project? What's your go-to geolocation service? Drop a comment below!
Need data from the web without writing scrapers? Check my *Apify actors** — ready-made scrapers for HN, Reddit, LinkedIn, and 75+ more sites. Or email: spinov001@gmail.com*
Top comments (0)