IP Geolocation API Free — Look Up Any IP Address
An IP geolocation API translates a raw IP address into human-readable location data — city, country, ISP, timezone, and more. Our free tool gives you a live API playground plus copy-ready code snippets in JavaScript, Python, cURL, and PHP, so you can integrate IP lookups into any project without signing up for a paid service.
What IP Geolocation Returns
When you query an IP address, the API resolves it against databases maintained by Regional Internet Registries (RIRs) and commercial data providers. A typical response includes:
- Geographic data — city, region, country, and ISO country code
- Network data — ISP name, organisation, and ASN (autonomous system number)
- Coordinates — latitude and longitude (city-level, not exact)
- Timezone — IANA timezone string, e.g.
America/Chicago - Flags —
isMobile,isProxy,isHosting
Geolocation is accurate to the city level for most IPs, but some IPs — especially mobile, satellite, or VPN exit nodes — map to a state or country only.
How to Use the IP Geolocation API Tool
- Open the IP Geolocation API tool.
- Click My IP to auto-fill your public IP, or type any IPv4 address into the input field.
- Hit Look Up IP. Results appear in six summary cards — IP, Location, ISP, Coordinates, Timezone, and ASN.
- The JSON Response panel shows the raw API output. Click the copy icon to grab it.
- Switch to the Code Examples tab and pick JavaScript, Python, cURL, or PHP to get integration code with the queried IP pre-filled.
Common Use Cases
| Use Case | API Field | Example Value |
|---|---|---|
| Display local currency or pricing | countryCode | "US" → show USD prices |
| Redirect to regional content | country | "Germany" → load /de/ route |
| Block or flag proxy/VPN traffic | isProxy | true → challenge the request |
| Show server-side timezone | timezone | "America/New_York" |
| Identify ISP for support logs | isp | "Comcast Cable" |
| Map visitor location | latitude + longitude | 37.38, -122.08 |
| Detect hosting/bot traffic | isHosting | true → log as automated visit |
| Mobile carrier detection | isMobile | true → serve mobile-optimised assets |
Advanced Workflows
Look Up a Visitor's Own IP Server-Side
In a Next.js route handler, read the x-forwarded-for header to get the real client IP even behind a load balancer:
// app/api/geo/route.ts
import { NextRequest, NextResponse } from 'next/server';
export async function GET(req: NextRequest) {
const forwarded = req.headers.get('x-forwarded-for');
const ip = forwarded?.split(',')[0].trim() ?? '8.8.8.8';
const res = await fetch(`https://www.publicsofttools.com/api/ip-geolocation?ip=${ip}`);
return NextResponse.json(await res.json());
}Combine with WHOIS for Full Domain Intelligence
Pair the IP geolocation API with the WHOIS lookup tool to build a complete picture of a domain: resolve the domain to its IP, geolocate the IP to find the hosting country, then WHOIS the domain to get the registrar and expiry date. Together these three data points help identify phishing domains, shadow IT assets, or misconfigured infrastructure.
Rate Limiting and Caching
The underlying upstream (ip-api.com free tier) allows 45 requests per minute. For production traffic, cache the geolocation result against the IP in Redis with a 24-hour TTL — IP-to-location mappings rarely change within a day. This also keeps latency under 5 ms for repeat visitors.
Detecting Proxy and Hosting IPs
The isProxy flag is true for known VPN exit nodes, Tor exit relays, and open proxies. The isHosting flag is true for cloud provider IP ranges (AWS, GCP, Azure, DigitalOcean). Use both together to route suspicious traffic to a CAPTCHA challenge without blocking legitimate users.
Building a Timezone-Aware UI
Use the timezone field with the browser's Intl.DateTimeFormat API to display times in the visitor's local zone before they interact with any settings — ideal for scheduling tools, event pages, and meeting planners. Cross-reference with our time zone converter to show offset from UTC.
Frequently Asked Questions
How accurate is IP geolocation?
City-level accuracy is typically 80–95% for residential broadband and fixed-line IPs. Mobile, satellite, and corporate VPN IPs often resolve only to a country or region. Accuracy also varies by country — the US and Western Europe have denser registration data than some other regions.
Does the API expose private or sensitive data?
No. IP geolocation returns the organisation or ISP assigned to an IP range — not a physical address, identity, or personal information. The city shown is the city associated with the ISP's POP (point of presence), which may be miles from the actual device location.
What is an ASN?
An Autonomous System Number (ASN) identifies a network operated by a single organisation under a unified routing policy. Large ISPs, cloud providers, and enterprises each have their own ASN. For example, Google's primary ASN is AS15169. The ASN field is useful for grouping traffic by carrier or detecting cloud-hosted bots.
Can I look up IPv6 addresses?
Yes — the API accepts both IPv4 (e.g. 8.8.8.8) and full IPv6 addresses. Coverage is slightly lower for IPv6 because many ISPs still route IPv6 traffic through the same city-level blocks as IPv4.
Is there a limit on how many IPs I can look up?
The free playground is intended for development and testing. For high-volume production use (thousands of requests per day), consider a dedicated geolocation service with a paid plan and an SLA. The playground tool is rate-limited to protect the shared endpoint.
Try the IP Geolocation API
Look up any IP address and get city, country, ISP, coordinates, timezone, and proxy status — plus copy-ready code in four languages.
Open IP Geolocation API