PublicSoftTools

IP Geolocation API — Free IP Location Lookup

Look up any IP address and get city, country, ISP, coordinates, and timezone as a clean JSON response. Includes a live API endpoint and integration examples in JavaScript, Python, cURL, and PHP. No signup required.

GEThttps://www.publicsofttools.com/api/ip-geolocation
Integration Examples
const res = await fetch('https://www.publicsofttools.com/api/ip-geolocation');
const data = await res.json();
// data.ip, data.city, data.country, data.isp …
console.log(data);

How the IP Geolocation API Works

  1. 1Enter any IPv4 or IPv6 address in the input field, or click My IP to look up your own public IP automatically.
  2. 2Click Lookup. The request goes to /api/ip-geolocation, which queries the ip-api.com geolocation database and returns a normalised JSON response.
  3. 3The summary cards show the key fields at a glance: location, ISP, coordinates, timezone, and ASN. The JSON panel shows the complete response you would receive when calling the endpoint from code.
  4. 4Copy the API endpoint URL and paste it into your project. Switch between the JavaScript, Python, cURL, and PHP tabs to get ready-to-use code snippets for your language.

API Response Format

Every successful response is a flat JSON object with consistent field names. Fields that have no data for a given IP are returned as null rather than being omitted, so your code can always destructure the same shape. The three boolean flags — isMobile, isProxy, and isHosting — default to false when the information is unavailable.

Error responses follow the same structure: a JSON object with an error string field and an appropriate HTTP status code (400 for invalid input, 404 for unresolvable IPs, 502 for upstream service failures).

Tips for Using IP Geolocation in Applications

Cache results aggressively

IP-to-location mappings rarely change more than once every few weeks. Cache geolocation results by IP address with a TTL of 24–48 hours to avoid repeated API calls for the same address and stay well within rate limits.

Never use for precise location

IP geolocation is not a substitute for GPS or explicit user location consent. City-level accuracy is typical but not guaranteed. Use it for soft defaults (pre-filling a country selector, routing to the nearest server) — not for anything requiring precise geography.

Check isProxy before trusting the location

If isProxy is true, the IP belongs to a VPN, proxy, or Tor exit node. The reported location is the proxy server's location, not the user's actual location. Factor this into any geo-based logic in your application.

Handle null fields gracefully

Not every IP resolves to a city or region. Always provide a fallback in your UI — show "Unknown" or skip the field rather than displaying "null" to users. Country-level data is available for most IPs even when city data is missing.

Use isHosting to detect data centre IPs

When isHosting is true, the IP belongs to a cloud provider, CDN, or data centre. This is useful for distinguishing real user traffic from bot or automated traffic in analytics and rate-limiting systems.

Pair with WHOIS for more detail

Geolocation tells you where an IP is physically located. WHOIS tells you who owns the IP block (the network operator or organisation). For security investigations, combine both: geolocation narrows the geography, WHOIS confirms the registrant.

Frequently Asked Questions

What data does the IP Geolocation API return?

Each response includes: IP address, city, region, region code, country name, country code, zip/postal code, latitude, longitude, timezone, ISP, organisation name, ASN, and three boolean flags — isMobile, isProxy, and isHosting. All fields are returned as a flat JSON object.

How do I call the API endpoint from my own code?

Send a GET request to https://www.publicsofttools.com/api/ip-geolocation?ip=8.8.8.8 — replacing 8.8.8.8 with any valid IPv4 or IPv6 address. Omit the ip parameter entirely to return geolocation data for the requesting IP address. The API returns JSON with Content-Type: application/json.

What does the "My IP" button do?

Clicking "My IP" sends a lookup request with no IP parameter. The server reads the IP address from the incoming HTTP request headers (x-forwarded-for or x-real-ip) and returns geolocation data for that address — your public IP as seen from the internet.

How accurate is the location data?

City-level accuracy is typically within 50–100 km for most IPs. Country-level accuracy is very high (over 99% for IPv4). Mobile carriers and VPN providers often report different regions from the user's physical location. Corporate IPs typically resolve to the organisation's headquarters or data centre, not individual users.

Why do some IPs return no city or region?

Not every IP has a precise location mapped in the geolocation database. Reserved address ranges, newly allocated IP blocks, and some corporate networks may return country-level data only, or no location data at all. Private ranges (10.x.x.x, 192.168.x.x, 172.16–31.x.x) are not routable on the public internet and will return an error.

What is the rate limit?

The underlying geolocation data comes from ip-api.com, which allows up to 45 requests per minute on the free tier. For production applications making higher volumes of requests, you should obtain your own API key from ip-api.com or a similar provider and call their service directly rather than routing through this tool.

Does the API support IPv6?

Yes. Pass any valid IPv6 address as the ip parameter. Geolocation coverage for IPv6 is less complete than for IPv4, so some IPv6 addresses may return fewer location fields.

Is this suitable for production use?

This tool is designed for development, testing, and learning — verifying integration code, exploring the API response format, and checking IP data for debugging. For production applications with high traffic, call a geolocation API provider directly with your own account and API key to ensure SLA guarantees, higher rate limits, and stable terms of service.