IP Geolocation API - Accurate Geolocation for IP Addresses

Experience accurate location tracking with our IP Geolocation API. This powerful API allows you to track IP address locations with precision, providing detailed information such as country, region, city, latitude, longitude, and time zone. Perfect for enhancing user insights and improving geographic analysis.

Our API simplifies the process to geolocate IP addresses with ease. By integrating our service, you gain valuable insights that support data-driven strategies and improve operational efficiency. Whether you are analyzing user behavior, managing network infrastructure, or planning geographically targeted campaigns, our IP Geolocation API offers reliable and precise location data to meet your needs.

10K Free Credits, No Credit Card Required

Features

Multilingual Support

Geolocation lookup supports response in multiple languages including English, German, Russian, Japanese, French, Chinese, Czech and Italian.

Globally Available (geoDNS)

Our servers are Globally Available in countries including UnitedStates, Germany, France, United Kingdom, Australia, Singapore and India. We route requests to the nearest and fastest node using Cloudflare's Global Network

Response Filtration

Specify what you want in query parameter and get only those fields. This will save you processing time, bandwidth and improve the API response time.

IP Security Information

Get the IP Security data along with the geolocation information.

IP Hostname Lookup

Hostname lookup can also be provided with the gelocation lookup via 3 different ways.

User-agent Information

Parse the user-agent string of a device with the geolocation lookup.

Documentation

API Endpoint

GET

https://api.apifreaks.com/v1.0/geolocation/lookup

Test
LANGUAGE
Python
PHP
Java
Node
Ruby
$ pip install requests

API Request

ParameterRequiredTypeDefaultDescription
ipNoString
IPv4, IPv6, or hostname whose geolocation lookup is required
langNoStringen
Response language. Possible values are: (1) en (English) (2) de (German) (3) ru (Russian) (4) ja (Japanese) (5) fr (French) (6) cn (Chinese Simplifed) (7) es (Spanish) (8) cs (Czech) (9) it (Italian)
fieldsNoArray
Comma separated list of fields to be included in the response. You may include an additional field labeled "geo" to represent geolocation fields, other than the individual response fields.
excludesNoArray
Comma separated list of fields except ip to be excluded in the response
includeNoArray
Possible values are: (1) security - To add ip security information (2) hostname - hostname lookup from IP-Hostname database and returns the same IP address if there is no hostname found for the queried IP address (3) liveHostname - hostname lookup from live sources (4) hostnameFallbackLive - hostname lookup from IP-Hostname database and if there is no hostname found for the queried IP address, then lookup through the live sources (5) useragent - To parse user-agent information from "User-Agent" header

API Response

FieldTypeRequirementDescription
domainStringOptional
Domain name that is used to lookup geolocation information. It is not returned if an IP address is used to query IP Geolocation API.
ipStringMandatory
IP address that is used to lookup geolocation information.
hostnameStringMandatory
Hostname of the IP address used to query IP Geolocation API.
continent_codeStringMandatory
2-letter code of the continent.
continent_nameStringMandatory
Name of the continent.
country_code2StringMandatory
Country code (ISO 3166-1 alpha-2) of the country.
country_code3StringMandatory
Country code (ISO 3166-1 alpha-3) of the country.
country_nameStringMandatory
Name of the country.
country_capitalStringMandatory
Name of the country's capital.
state_provStringOptional
Name of the state/province/region.
districtStringOptional
Name of the district or county.
cityStringOptional
Name of the city.
zip_codeStringOptional
ZIP code of the place.
latitudeFloatMandatory
Latitude of the place.
longitudeFloatMandatory
Longitude of the place.
is_euBooleanMandatory
Is the country belongs to European Union?
calling_codeStringMandatory
Calling code of the country.
country_tldStringMandatory
Top-level domain of the country.
languagesStringMandatory
Comma-separated list of the languages' codes, spoken in the country.
country_flagStringMandatory
URL to get the country flag.
geoname_idNumberMandatory
Geoname ID of the place from geonames.org
ispStringMandatory
Name of the ISP holding the IP address.
connection_typeStringOptional
Type of the connection, consuming the IP address.
organizationStringOptional
Name of AS organization holding the IP address.
asnStringOptional
Autonomous system number of the autonomous system, to which IP address belongs to.
currency.codeStringMandatory
Currency code (ISO 4217).
currency.nameStringMandatory
Currency name (ISO 4217).
currency.symbolStringMandatory
Currency symbol.
time_zone.nameStringMandatory
Name (ISO 8601) of the time zone.
time_zone.offsetNumberMandatory
Time zone offset from UTC.
timezone.current_timeStringMandatory
Current time in 'yyyy-MM-dd HH:mm:ss.SSS+ZZZ' format.
timezone.current_time_unixFloatMandatory
Current time in seconds since 1970.
timezone.is_dstBooleanMandatory
Is the time zone in daylight savings?
timezone.dst_savingsNumberMandatory
Total daylight savings.
security.threat_scoreNumberMandatory
IP address's threat score. It ranges from 0 (lowest threat) to 100 (highest threat).
security.is_torBooleanMandatory
Indicates if the IP address is being consumed on a Tor endpoint.
security.is_proxyBooleanMandatory
Indicates if the IP address belongs to a proxy network.
security.proxy_typeStringOptional
Type of the proxy network if the IP address belongs to a proxy network.
security.is_anonymousBooleanMandatory
Indicates if the IP address is being used anonymously.
security.is_known_attackerBooleanMandatory
Indicates if the IP address is enlisted as an attacking IP address.
security.is_cloud_providerBooleanMandatory
Indicates if the IP address belongs to a cloud provider (computing infrastructure providers).
user_agent.userAgentStringStringMandatory
User-Agent string passed along with the query in the User-Agent header.
user_agent.nameStringMandatory
User-Agent Name.
user_agent.typeStringMandatory
User-Agent Class.
user_agent.versionStringMandatory
User-Agent Version.
user_agent.versionMajorStringMandatory
User-Agent Version Major.
user_agent.device.nameStringMandatory
Device Name.
user_agent.device.typeStringMandatory
Device Type.
user_agent.device.brandStringMandatory
Device Brand.
user_agent.device.CPUStringMandatory
Device CPU Model.
user_agent.engine.nameStringMandatory
Layout Engine Name.
user_agent.engine.typeStringMandatory
Layout Engine Class.
user_agent.engine.versionStringMandatory
Layout Engine Version.
user_agent.engine.versionMajorStringMandatory
Layout Engine Version Major.
user_agent.operatingSystem.nameStringMandatory
Operating System Name.
user_agent.operatingSystem.typeStringMandatory
Operating System Class.
user_agent.operatingSystem.versionStringMandatory
Operating System Version.
user_agent.operatingSystem.versionMajorStringMandatory
Operating System Version Major.

HTTP Error Codes

HTTP StatusReasons
404
It is returned if the queried IP address or domain name is not found in our database.
423
If the queried IP address is a bogon (bogus IP address from the bogon space) IP address.

How-To-Guides

Lookup by IPv4, IPv6 address or hostname

The IP Location API can be utilized to lookup any IP address or domain name. To determine the geolocation of an IP address, include the ip query parameter in your request with the desired IPv4 or IPv6 address value.

#  Get geolocation for an IPv4 Address = 8.8.8.8
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8'
# Get geolocation for an IPv6 address = 2001:4860:4860::1
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=2001:4860:4860::1'
# Response for IPv4 address = 8.8.8.8 { "ip": "8.8.8.8", "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": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421", "is_eu": false, "calling_code": "+1", "country_tld": ".us", "languages": "en-US,es-US,haw,fr", "country_flag": "https://ipgeolocation.io/static/flags/us_64.png", "geoname_id": "6301403", "isp": "Google LLC", "connection_type": "", "organization": "Google LLC", "country_emoji": "🇺🇸", "asn": "AS15169", "currency": { "code": "USD", "name": "US Dollar", "symbol": "$" }, "time_zone": { "name": "America/Los_Angeles", "offset": -8, "offset_with_dst": -7, "current_time": "2024-08-05 07:56:09.503-0700", "current_time_unix": 1722869769.503, "is_dst": true, "dst_savings": 1, "dst_exists": true, "dst_start": { "utc_time": "2024-03-10 TIME 10", "duration": "+1H", "gap": true, "dateTimeAfter": "2024-03-10 TIME 03", "dateTimeBefore": "2024-03-10 TIME 02", "overlap": false }, "dst_end": { "utc_time": "2024-11-03 TIME 09", "duration": "-1H", "gap": false, "dateTimeAfter": "2024-11-03 TIME 01", "dateTimeBefore": "2024-11-03 TIME 02", "overlap": true } } }

To determine the geolocation and IP details of a hostname, include the ip query parameter in your request with the desired hostname value. This enables precise geolocation lookup for any domain name, providing detailed IP address information.

#  Get geolocation for a hostname = dns.google.com
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=dns.google.com'
# Response { "domain": "dns.google.com", "ip": "8.8.4.4", "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": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421", "is_eu": false, "calling_code": "+1", "country_tld": ".us", "languages": "en-US,es-US,haw,fr", "country_flag": "https://ipgeolocation.io/static/flags/us_64.png", "geoname_id": "6301403", "isp": "Google LLC", "connection_type": "", "organization": "Google LLC", "country_emoji": "🇺🇸", "asn": "AS15169", "currency": { "code": "USD", "name": "US Dollar", "symbol": "$" }, "time_zone": { "name": "America/Los_Angeles", "offset": -8, "offset_with_dst": -7, "current_time": "2024-08-05 07:54:32.578-0700", "current_time_unix": 1722869672.578, "is_dst": true, "dst_savings": 1, "dst_exists": true, "dst_start": { "utc_time": "2024-03-10 TIME 10", "duration": "+1H", "gap": true, "dateTimeAfter": "2024-03-10 TIME 03", "dateTimeBefore": "2024-03-10 TIME 02", "overlap": false }, "dst_end": { "utc_time": "2024-11-03 TIME 09", "duration": "-1H", "gap": false, "dateTimeAfter": "2024-11-03 TIME 01", "dateTimeBefore": "2024-11-03 TIME 02", "overlap": true } } }

Lookup by Client's request IP

When you call the IP to Location API without specifying an ip query parameter, it automatically returns the geolocation information of the client request IP. This feature simplifies obtaining geolocation data for the client's IP, streamlining the process and enhancing the usability of the API.

#  Get geolocation for client's request IP
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY'
{ "ip": "39.60.254.143", "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": "", "city": "Lahore", "zipcode": "54000", "latitude": "31.52037", "longitude": "74.35875", "is_eu": false, "calling_code": "+92", "country_tld": ".pk", "languages": "ur-PK,en-PK,pa,sd,ps,brh", "country_flag": "https://ipgeolocation.io/static/flags/pk_64.png", "geoname_id": "7043715", "isp": "Pakistan Telecommuication company limited", "connection_type": "", "organization": "Pakistan Telecommuication company limited", "country_emoji": "🇵🇰", "asn": "AS17557", "currency": { "code": "PKR", "name": "Pakistan Rupee", "symbol": "₨" }, "time_zone": { "name": "Asia/Karachi", "offset": 5, "offset_with_dst": 5, "current_time": "2024-08-06 15:30:33.657+0500", "current_time_unix": 1722940233.657, "is_dst": false, "dst_savings": 0, "dst_exists": false, "dst_start": "", "dst_end": "" } }

JSON / XML Response Format

To customize the response format of your IP geolocation lookup, use the format parameter in your request. If you do not specify a format, the default response will be in JSON. To receive the response in XML format, simply include the format query parameter with the value xml. This flexibility ensures you get the IP geolocation data in the format that best suits your needs, whether it's JSON or XML.

# Get geolocation data in xml format
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&format=xml'
# xml Response <Map> <ip>8.8.8.8</ip> <continent_code>NA</continent_code> <continent_name>North America</continent_name> <country_code2>US</country_code2> <country_code3>USA</country_code3> <country_name>United States</country_name> <country_name_official>United States of America</country_name_official> <country_capital>Washington, D.C.</country_capital> <state_prov>California</state_prov> <state_code>US-CA</state_code> <district></district> <city>Mountain View</city> <zipcode>94043-1351</zipcode> <latitude>37.42240</latitude> <longitude>-122.08421</longitude> <is_eu>false</is_eu> <calling_code>+1</calling_code> <country_tld>.us</country_tld> <languages>en-US,es-US,haw,fr</languages> <country_flag>https://ipgeolocation.io/static/flags/us_64.png</country_flag> <geoname_id>6301403</geoname_id> <isp>Google LLC</isp> <connection_type></connection_type> <organization>Google LLC</organization> <country_emoji>🇺🇸</country_emoji> <asn>AS15169</asn> <currency> <code>USD</code> <name>US Dollar</name> <symbol>$</symbol> </currency> <time_zone> <name>America/Los_Angeles</name> <offset>-8</offset> <offset_with_dst>-7</offset_with_dst> <current_time>2024-08-05 08:07:49.373-0700</current_time> <current_time_unix>1722870469.373</current_time_unix> <is_dst>true</is_dst> <dst_savings>1</dst_savings> <dst_exists>true</dst_exists> <dst_start> <utc_time>2024-03-10 TIME 10</utc_time> <duration>+1H</duration> <gap>true</gap> <dateTimeAfter>2024-03-10 TIME 03</dateTimeAfter> <dateTimeBefore>2024-03-10 TIME 02</dateTimeBefore> <overlap>false</overlap> </dst_start> <dst_end> <utc_time>2024-11-03 TIME 09</utc_time> <duration>-1H</duration> <gap>false</gap> <dateTimeAfter>2024-11-03 TIME 01</dateTimeAfter> <dateTimeBefore>2024-11-03 TIME 02</dateTimeBefore> <overlap>true</overlap> </dst_end> </time_zone> </Map>

Response Filtration

The IP to Location API is designed for precise geolocation data retrieval. By specifying the desired fields in the query parameters, you can tailor the response to include only the information you need. This level of customization ensures you get targeted and relevant geolocation data, enhancing the efficiency of your IP lookup and geolocation tasks. You can customize the API response in two efficient ways:

  1. Use the fields query parameter with a comma-separated list of desired fields to include only those in the response.
  2. Use the excludes query parameter with a comma-separated list of fields you wish to omit from the response.
# Get city information only
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=city'
{ "ip": "8.8.8.8", "city": "Mountain View" } # Get the country name and country code (ISO2) only
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=country_code2,country_name'
{ "ip": "8.8.8.8", "country_code2": "US", "country_name": "United States", "country_name_official": "United States of America" } # Get time zone information only
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=time_zone'
{ "ip": "8.8.8.8", "time_zone": { "name": "America/Los_Angeles", "offset": -8, "offset_with_dst": -7, "current_time": "2024-08-06 00:26:36.865-0700", "current_time_unix": 1722929196.865, "is_dst": true, "dst_savings": 1, "dst_exists": true, "dst_start": { "utc_time": "2024-03-10 TIME 10", "duration": "+1H", "gap": true, "dateTimeAfter": "2024-03-10 TIME 03", "dateTimeBefore": "2024-03-10 TIME 02", "overlap": false }, "dst_end": { "utc_time": "2024-11-03 TIME 09", "duration": "-1H", "gap": false, "dateTimeAfter": "2024-11-03 TIME 01", "dateTimeBefore": "2024-11-03 TIME 02", "overlap": true } } } # Get geolocation only
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo'
{ "ip": "8.8.8.8", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "state_prov": "California", "state_code": "US-CA", "district": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421" } # Exclude the continent code, currency, and time zone information
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&excludes=continent_code,currency,time_zone'
{ "ip": "8.8.8.8", "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": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421", "is_eu": false, "calling_code": "+1", "country_tld": ".us", "languages": "en-US,es-US,haw,fr", "country_flag": "https://ipgeolocation.io/static/flags/us_64.png", "geoname_id": "6301403", "isp": "Google LLC", "connection_type": "", "organization": "Google LLC", "country_emoji": "🇺🇸", "asn": "AS15169" } # Get the geolocation and exclude the continent information
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&excludes=continent_code'
{ "ip": "8.8.8.8", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "state_prov": "California", "state_code": "US-CA", "district": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421" }

IP Security Information

The IP Geolocation API also provides valuable IP-Security information, though it is not included by default. To receive IP-Security details alongside geolocation data, add the include=security query parameter to your request. This addition ensures comprehensive insights with your IP geolocation results, significantly enhancing the value and utility of your API usage.

# Get the IP security information
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=security'
{ "ip": "8.8.8.8", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "state_prov": "California", "state_code": "US-CA", "district": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421", "security": { "threat_score": 80, "is_tor": false, "is_proxy": true, "proxy_type": "VPN", "is_anonymous": true, "is_known_attacker": true, "is_spam": false, "is_bot": false, "is_cloud_provider": true } }

IP Hostname Lookup

The IPGeolocation API also offers hostname lookup for IP addresses, though this feature is not enabled by default. To obtain hostname information along with geolocation data, you can use include query parameter with these three specific values:

  1. hostname: Performs a hostname lookup from the IP-Hostname database. If no hostname is found, the response will return the queried IP address.
  2. liveHostname: Conducts a hostname lookup from live sources, providing the most current hostname information.
  3. hostnameFallbackLive: First attempts a hostname lookup from the IP-Hostname database. If no hostname is found, it then falls back to live sources for the lookup.

By leveraging these parameters, you can enrich your geolocation data with precise hostname information, enhancing the comprehensiveness and accuracy of your IP lookups.

# hostname lookup from IP hostname database
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=hostname'
{ "ip": "8.8.8.8", "hostname": "8.8.8.8", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "state_prov": "California", "state_code": "US-CA", "district": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421" } # hostname lookup from live sources
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=liveHostname'
{ "ip": "8.8.8.8", "hostname": "dns.google", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "state_prov": "California", "state_code": "US-CA", "district": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421" } # hostname lookup from IP hostname database with fallback to live sources
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=hostnameFallbackLive'
{ "ip": "8.8.8.8", "hostname": "8.8.8.8", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "state_prov": "California", "state_code": "US-CA", "district": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421" }

User-agent Parsing

The IP to Location API can also parse the user-agent string from the "User-Agent" header. To enable user-agent string parsing, simply add the include=useragent query parameter to your request. This feature enhances your geolocation data by providing detailed user-agent information, making your IP lookups even more informative and valuable.

# parse user-agent string along with IP geolocation lookup
curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=useragent'
{ "ip": "8.8.8.8", "country_code2": "US", "country_code3": "USA", "country_name": "United States", "country_name_official": "United States of America", "state_prov": "California", "state_code": "US-CA", "district": "", "city": "Mountain View", "zipcode": "94043-1351", "latitude": "37.42240", "longitude": "-122.08421", "user_agent": { "userAgentString": "curl/7.81.0", "name": "Curl", "type": "Robot", "version": "7.81.0", "versionMajor": "7", "device": { "name": "Curl", "type": "Robot", "brand": "Curl", "cpu": "Unknown" }, "engine": { "name": "curl", "type": "Robot", "version": "7.81.0", "versionMajor": "7" }, "operatingSystem": { "name": "Cloud", "type": "Cloud", "version": "??", "versionMajor": "??" } } }

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.

For each successful request, 1 credit is charged for basic geolocation data. If you need additional information—such as user-agent parsing, IP security details, or IP hostname data—an extra credit will be charged. By including the include parameter to request these features, the total cost per request will be 2 credits.

ServiceCredits
Basic Geolocation Data1 Credit per successful request
Geolocation + User-Agent Parsing2 Credits per successful request
Geolocation + User-Agent Parsing2 Credits per successful request
Geolocation + IP Hostname Details2 Credits per successful request

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.

Price Estimation Calculator