IP2Location API

⭐ Beginner's Pick Geocoding / API Key Intermediate HTTPS
Varies by plan (check documentation)

Overview

IP2Location is a geolocation web service that maps any IP address to its physical location and network information. It returns over 55 data points including country, city, latitude, longitude, ISP, and time zone. It is a great starting point for personalizing content based on user location.

💡

Beginner Tip

Start with the free demo key (use "demo" as the key) to test the API response format before signing up. The free tier returns limited fields, so check the documentation to see which parameters require a paid plan.

Available Data

IP address details
latitude and longitude
city and country
timezone
ISP information
IP address information

Example Response

JSON Response
{
  "ip": "203.0.113.42",
  "city": "San Francisco",
  "region": "California",
  "country_code": "US",
  "latitude": 37.7749,
  "longitude": -122.4194,
  "timezone": "America/Los_Angeles",
  "isp": "Example ISP"
}

Field Reference

country_code Two-letter ISO 3166-1 country code, e.g. "US" for the United States.
country_name Full English name of the country associated with the IP.
city_name Name of the city where the IP is registered.
latitude Approximate latitude of the IP location in decimal degrees.
longitude Approximate longitude of the IP location in decimal degrees.
time_zone IANA time zone identifier for the IP location, e.g. "America/New_York".

Implementation Example

const url = "https://www.ip2location.com/web-service/ip2location";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

INVALID API KEY The API key is missing or incorrect.
Double-check your key from the IP2Location dashboard and pass it as the key query parameter.
Empty or null response You passed a private/reserved IP (e.g. 192.168.x.x) that cannot be geolocated.
Use a public IP address. For testing, use a well-known IP such as 8.8.8.8.
429 Too Many Requests You have exceeded the request quota for your plan.
Check your monthly usage in the dashboard, or upgrade your plan for higher limits.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 10/20
🔒 Security 15/15
🛠 Developer XP 12/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth API Key
HTTPS REQUIRED
CORS UNKNOWN
Category Geocoding
Difficulty Intermediate
Verified: 2026-04-04

Similar APIs

View All →