IP Geolocation API - City, Country, Coordinates & ISP Data
Every request that reaches your application identifies itself with nothing but an IP address - no country for compliance, no currency for pricing, no hint whether it's a home connection or a datacenter. The IP Geolocation API resolves any IPv4 or IPv6 address, or a hostname, into its physical location and network owner in a single REST call. One response carries the full location hierarchy down to city and coordinates, the ISP and Autonomous System behind the address, the announced network route, and the local timezone and currency - with optional accuracy scoring, hostname, and abuse-contact data on request. It's built for developers who need an IP location API behind geo-targeted content, checkout risk screening, and log enrichment - without shipping and maintaining a local IP database. Start with 10,000 free credits, no credit card required - a free IP geolocation API while you integrate.
Features
Full Location Hierarchy
The location object resolves an address from the continent down through country, state or region (with its ISO code), district, and city, alongside zipcode, latitude, longitude, and an is_eu flag for EU-membership checks. When a decision needs to know how far to trust the pin, add include=geo_accuracy and the same response carries accuracy_radius in kilometres, a confidence rating, and the locality.
Use it as an IP address lookup API for country- and city-level personalisation, regional routing, and analytics segmentation.
Network, Operator & Company Data
Every lookup names who is behind the address: the top-level asn object carries the as_number, the organization that holds it, its type, and the rir it belongs to, while the network object reports the connection_type, the announced route, and an is_anycast flag. The companyobject maps the IP to the operating business and whether it's a hosting provider.
Use it to separate consumer, business, and datacenter traffic. For dedicated Autonomous System queries - BGP peers and full CIDR ranges - call the ASN Lookup API.
Timezone and Currency, Built In
The base response includes a full time_zone object - IANA name, UTC offset with and without DST, the current local time, and the exact DST transition windows (dst_start, dst_end) with gap and overlap flags - plus the local currency code, name, and symbol.
Scheduling, logging, and display logic get everything they need from the geolocation call itself, with no second request.
Response Filtering, Formats & Languages
The fields parameter trims any response to a dot-notation list of only the values your application reads - location.city, asn.organization - and excludesdrops what you don't need, cutting payload size and parsing overhead on high-volume calls. Responses are JSON by default and available as XML via format=xml. The lang parameter localises place names into twelve languages, including English, German, Japanese, Spanish, Chinese (Simplified), Korean, Persian, and Portuguese.
Optional Enrichments
The include parameter adds optional objects to the same response: geo_accuracy scoring, hostname resolution (from a database, live sources, or both), the abuse contact for the address, the US dma_code for regional ad targeting, and parsed user_agent information - or * to add every module in one call. Full IP threat intelligence - VPN, proxy, and Tor detection with a threat score and attacker, bot, and spam signals - is available as the security add-on. If you need those risk signals on their own or at scale, the dedicated IP Threat Intelligence API screens up to 50,000 IPs per request.
Built for These Use Cases
Geo-targeted content and pricing
Read the country and region from each lookup to localise language, content, and compliance rules at the edge of a request. To show prices in the visitor's own currency from the same IP, pair this with the Geolocalized Currency Converter.Signup and checkout risk screening
Compare the IP's country against the billing country to flag mismatches at registration or payment. When a session needs a real risk decision - proxy, VPN, Tor, or known-attacker signals with a single score - route the IP to the IP Threat Intelligence API and act on the result.Log and analytics enrichment
Resolve raw IPs in event logs to city, country, and operator before they reach your warehouse, so dashboards can segment by geography and network type. For datasets larger than a single address per call, the Bulk IP Geolocation Lookup processes up to 50,000 IPs in one request.Traffic and operator attribution
Read the operating organisation and network type from each lookup to separate consumer-ISP traffic from datacenter and hosting providers - useful for telling real users apart from server-to-server calls in reporting.
API Endpoint
$ pip install requestsimport requests
url = "https://api.apifreaks.com/v2.0/geolocation/lookup?ip=8.8.8.8&lang=en&fields=location&include=security%2ChostnameFallbackLive"
payload = {}
headers = {
'X-apiKey': 'API-KEY'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
How-To-Guides
Look Up an IP, IPv6, or Hostname
Most integrations start here: a request arrives and you need to know where it came from and who runs the network before deciding what to serve. Whether the IP lookup API sits behind a signup flow or a log pipeline, pass the address in the ip parameter - any IPv4 or IPv6 address, or a hostname the API resolves before locating. One call returns the location hierarchy, the asn operator, the company, the network route, and the time_zone and currency.
# Geolocate an IPv4 address (an IPv6 address or hostname works the same way){ "ip": "8.8.8.8", "location": { "continent_code": "NA", "continent_name": "North America", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "country_capital": "Washington, D.C.", "state_prov": "California", "state_code": "US-CA", "district": "Santa Clara", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421", "is_eu": false, "country_flag": "https://ipgeolocation.io/static/flags/us_64.png", "geoname_id": "6301403", "country_emoji": "🇺🇸" }, "country_metadata": { "calling_code": "+1", "tld": ".us", "languages": ["en-US", "es-US", "haw", "fr"] }, "network": { "connection_type": "", "route": "8.8.8.0/24", "is_anycast": true }, "currency": { "code": "USD", "name": "US Dollar", "symbol": "$" }, "asn": { "as_number": "AS15169", "organization": "Google LLC", "country": "US", "type": "BUSINESS", "domain": "google.com", "date_allocated": "2000-03-30", "rir": "ARIN" }, "company": { "name": "Google LLC", "type": "HOSTING", "domain": "google.com" }, "time_zone": { "name": "America/Los_Angeles", "offset": -8, "offset_with_dst": -7, "current_time": "2026-07-08 03:37:17.906-0700", "current_time_unix": 1783507037.906, "current_tz_abbreviation": "PDT", "current_tz_full_name": "Pacific Daylight Time", "standard_tz_abbreviation": "PST", "standard_tz_full_name": "Pacific Standard Time", "is_dst": true, "dst_savings": 1, "dst_exists": true, "dst_tz_abbreviation": "PDT", "dst_tz_full_name": "Pacific Daylight Time", "dst_start": { "utc_time": "2026-03-08 TIME 10:00", "duration": "+1.00H", "gap": true, "date_time_after": "2026-03-08 TIME 03:00", "date_time_before": "2026-03-08 TIME 02:00", "overlap": false }, "dst_end": { "utc_time": "2026-11-01 TIME 09:00", "duration": "-1.00H", "gap": false, "date_time_after": "2026-11-01 TIME 01:00", "date_time_before": "2026-11-01 TIME 02:00", "overlap": true } } }curl -X 'GET' 'https://api.apifreaks.com/v2.0/geolocation/lookup?ip=8.8.8.8&apiKey=API-KEY'
Get Only the Country, City, Coordinates, or ISP
High-volume paths rarely need the full response - a paywall check needs the country, a map pin needs coordinates, a traffic report needs the operator. Use fields with a comma-separated, dot-notation list to return only the values your code reads, or excludesto drop what you don't need; the classic IP-to-country API call becomes a one-line response.
# Country code only{ "ip": "8.8.8.8", "location": { "country_code2": "US" } } # Coordinates onlycurl -X 'GET' 'https://api.apifreaks.com/v2.0/geolocation/lookup?ip=8.8.8.8&fields=location.country_code2&apiKey=API-KEY'{ "ip": "8.8.8.8", "location": { "latitude": "37.42240", "longitude": "-122.08421" } } # The operator (ISP / organization) behind the IPcurl -X 'GET' 'https://api.apifreaks.com/v2.0/geolocation/lookup?ip=8.8.8.8&fields=location.latitude,location.longitude&apiKey=API-KEY'{ "ip": "8.8.8.8", "asn": { "organization": "Google LLC", "type": "BUSINESS" } }curl -X 'GET' 'https://api.apifreaks.com/v2.0/geolocation/lookup?ip=8.8.8.8&fields=asn.organization,asn.type&apiKey=API-KEY'
For dedicated Autonomous System data - full CIDR ranges and BGP peers - pass the AS number to the ASN Lookup API.
Geolocate the Client's Request IP
When the caller is the device you want to locate - a CLI tool, a mobile client, an edge function - skip the ip parameter entirely and the API locates the address the request came from. To geolocate a visitor from your backend instead, read the client address your framework exposes (for example X-Forwarded-For) and pass it as ip - the no-parameter form locates whoever makes the call, which from a server is the server itself.
# Geolocate the requesting IP{ "ip": "39.63.38.164", "location": { "continent_code": "AS", "continent_name": "Asia", "country_code2": "PK", "country_code3": "PAK", "country_name": "Pakistan", "country_name_official": "Islamic Republic of Pakistan", "country_capital": "Islamabad", "state_prov": "Punjab", "state_code": "PK-PB", "district": "Lahore", "city": "Lahore", "zipcode": "54000", "latitude": "31.52037", "longitude": "74.35875", "is_eu": false, "country_flag": "https://ipgeolocation.io/static/flags/pk_64.png", "geoname_id": "7043715", "country_emoji": "🇵🇰" }, "country_metadata": { "calling_code": "+92", "tld": ".pk", "languages": ["ur-PK", "en-PK", "pa", "sd", "ps", "brh"] }, "network": { "connection_type": "", "route": "39.63.32.0/19", "is_anycast": false }, "currency": { "code": "PKR", "name": "Pakistan Rupee", "symbol": "₨" }, "asn": { "as_number": "AS17557", "organization": "Pakistan Telecommunication Company Limited", "country": "PK", "type": "ISP", "domain": "ptcl.net", "date_allocated": "", "rir": "APNIC" }, "company": { "name": "Pakistan Telecommuication company limited", "type": "ISP", "domain": "ptcl.com.pk" } }curl -X 'GET' 'https://api.apifreaks.com/v2.0/geolocation/lookup?apiKey=API-KEY'
Add Optional Data with include
Some decisions need more than the base response: a fraud check wants risk signals in the same call, an abuse report needs a contact on file, a delivery estimate needs to know how far to trust the coordinates. The include parameter adds optional objects to the same response - combine several with commas (include=hostname,security) or pass include=* for every module at once.
include= value | Adds to the response |
|---|---|
| geo_accuracy | Adds accuracy_radius, confidence, and locality to the location object. |
| dma_code | US Designated Market Area code for regional ad targeting (US IPs only). |
| hostname · liveHostname · hostnameFallbackLive | Reverse hostname for the IP - from the stored database, from live sources, or database-then-live fallback. |
| security | IP risk signals - VPN, proxy, and Tor detection with a threat score. For risk decisions or screening at scale, use the dedicated IP Threat Intelligence API. |
| user_agent | Parses the request's User-Agent into browser, OS, and device. For user-agent parsing on its own, use the User Agent Parser API. |
| abuse | Network abuse-contact record for the IP's range (email, phone). |
| * | Include all additional data modules in a single response. |
# Add hostname to a geolocation lookup{ "ip": "8.8.8.8", "hostname": "dns.google", "location": { "city": "Mountain View" } }curl -X 'GET' 'https://api.apifreaks.com/v2.0/geolocation/lookup?ip=8.8.8.8&include=hostname&fields=location.city&apiKey=API-KEY'
Adding security or abuse raises the credit cost of the call. Pass include=*for every module at a flat 8 credits - see Pricing. The other values don't change the cost.
Get Localized Place Names, in JSON or XML
Anything user-facing reads better in the reader's own language, and anything feeding an XML pipeline shouldn't need a conversion step. Set lang to return place names in any of twelve languages - en, de, ru, ja, fr, cn, es, cs, it, ko, fa, pt. Responses default to JSON; pass format=xml for XML.
# City and country in German{ "ip": "8.8.8.8", "location": { "city": "Mountain View", "country_name": "Vereinigte Staaten" } }curl -X 'GET' 'https://api.apifreaks.com/v2.0/geolocation/lookup?ip=8.8.8.8&lang=de&fields=location.city,location.country_name&apiKey=API-KEY'
Frequently Asked Questions
Pricing
To use the IP Geolocation API, you will need API credits. We only charge for successful queries, defined by a 2xx status code. If your request results in a 4xx or 5xx status code, no credits will be charged, and any deducted credits will be returned.
| Service | Credits |
|---|---|
| IP Geolocation (base) | 2 |
| + IP Security (include=security) | 6 |
| + Abuse Contact (include=abuse) | 6 |
| + IP Security + Abuse (include=security,abuse) | 10 |
| + All Additional Modules (include=*) | 10 |
Utilize the Credits Usage API to efficiently monitor your recent consumption of both one-off and subscription credits. This API provides a streamlined way to track and manage your credit usage, ensuring you stay informed about your remaining balance and can optimize your resource allocation effectively.