IP Geolocation
free/v1/ip/geolocationReturns geographic location data for any IPv4 or IPv6 address including continent, country (ISO 3166-1), region/subdivision (ISO 3166-2), city, coordinates, timezone, postal code, and ASN/organization details. Powered by Cloudflare's edge network for low-latency lookups worldwide.
What It Does
Resolves the physical location associated with an IP address using Cloudflare's geolocation database at the edge. Returns structured data including continent code, country (with ISO 3166-1 alpha-2 code), region/subdivision (ISO 3166-2), city, latitude/longitude coordinates, IANA timezone identifier, postal code where available, and the Autonomous System Number (ASN) with organization name operating the IP range.
Why It's Useful
IP geolocation is foundational for fraud detection, content localization, GDPR/regulatory compliance, and user analytics. It enables security engineers to detect impossible travel attacks, product teams to serve localized content and pricing, and compliance teams to enforce geographic access controls mandated by regulations like GDPR, CCPA, and data sovereignty laws.
Use Cases
Impossible Travel Detection
Compare the geographic location of successive login attempts to detect physically impossible travel patterns (e.g., logins from New York and Tokyo within 30 minutes).
Automatically flag or block account takeover attempts from geographically inconsistent locations.
Content Localization & Pricing
Serve localized content, currency, and regional pricing based on visitor IP geolocation without requiring manual user selection.
Increase conversion rates with location-appropriate content, pricing in local currency, and locale-specific offers.
Regulatory Compliance & Geofencing
Enforce geographic access restrictions for content or services regulated under GDPR, CCPA, sanctions (OFAC), or data residency requirements.
Meet data sovereignty and regulatory requirements by restricting access to approved geographic regions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
ip | string | Required | The IPv4 or IPv6 address to geolocate. Omit to geolocate the requesting client IP.Example: 8.8.8.8 |
Response Fields
| Field | Type | Description |
|---|---|---|
ip | string | The queried IP address |
ip_version | number | IP version (4 or 6) |
country | string | Country name |
country_code | string | ISO 3166-1 alpha-2 country code |
region | string | State, province, or region name |
city | string | City name |
postal_code | string | Postal/ZIP code where available |
latitude | number | Latitude coordinate |
longitude | number | Longitude coordinate |
timezone | string | IANA timezone identifier (e.g., America/New_York) |
asn | number | Autonomous System Number |
organization | string | ASN organization name (ISP or hosting provider) |
is_bogon | boolean | Whether the IP is a bogon (reserved/private) address |
Code Examples
curl "https://api.edgedns.dev/v1/ip/geolocation" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d "ip=8.8.8.8"const response = await fetch(
'https://api.edgedns.dev/v1/ip/geolocation?ip=8.8.8.8',
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
}
);
const data = await response.json();
console.log(data);import requests
response = requests.get(
'https://api.edgedns.dev/v1/ip/geolocation',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={
'ip': '8.8.8.8'
}
)
data = response.json()
print(data)Read the full IP Geolocation guide
Why it matters, real-world use cases, parameters, response fields, and how to call it from Claude, ChatGPT, or Gemini via MCP.
Read the guide →Related Endpoints
External References
Learn more about the standards and protocols behind this endpoint.
Try This Endpoint
Test the IP Geolocation endpoint live in the playground.