Skip to main content

IP Geolocation

free
GET/v1/ip/geolocation

Returns 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

Security Engineer

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.

Product Manager

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.

Compliance Officer

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

NameTypeRequiredDescription
ipstringRequiredThe IPv4 or IPv6 address to geolocate. Omit to geolocate the requesting client IP.Example: 8.8.8.8

Response Fields

FieldTypeDescription
ipstringThe queried IP address
ip_versionnumberIP version (4 or 6)
countrystringCountry name
country_codestringISO 3166-1 alpha-2 country code
regionstringState, province, or region name
citystringCity name
postal_codestringPostal/ZIP code where available
latitudenumberLatitude coordinate
longitudenumberLongitude coordinate
timezonestringIANA timezone identifier (e.g., America/New_York)
asnnumberAutonomous System Number
organizationstringASN organization name (ISP or hosting provider)
is_bogonbooleanWhether the IP is a bogon (reserved/private) address

Code Examples

cURL
curl "https://api.edgedns.dev/v1/ip/geolocation" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d "ip=8.8.8.8"
JavaScript
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);
Python
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.