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.
Geolocation lookup supports response in multiple languages including English, German, Russian, Japanese, French, Chinese, Czech and Italian.
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
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.
Get the IP Security data along with the geolocation information.
Hostname lookup can also be provided with the gelocation lookup via 3 different ways.
Parse the user-agent string of a device with the geolocation lookup.
$ pip install requests
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
ip | No | String | IPv4, IPv6, or hostname whose geolocation lookup is required | |
lang | No | String | en | 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) |
fields | No | Array | 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. | |
excludes | No | Array | Comma separated list of fields except ip to be excluded in the response | |
include | No | Array | 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 |
Field | Type | Requirement | Description |
---|---|---|---|
domain | String | Optional | Domain name that is used to lookup geolocation information. It is not returned if an IP address is used to query IP Geolocation API. |
ip | String | Mandatory | IP address that is used to lookup geolocation information. |
hostname | String | Mandatory | Hostname of the IP address used to query IP Geolocation API. |
continent_code | String | Mandatory | 2-letter code of the continent. |
continent_name | String | Mandatory | Name of the continent. |
country_code2 | String | Mandatory | Country code (ISO 3166-1 alpha-2) of the country. |
country_code3 | String | Mandatory | Country code (ISO 3166-1 alpha-3) of the country. |
country_name | String | Mandatory | Name of the country. |
country_capital | String | Mandatory | Name of the country's capital. |
state_prov | String | Optional | Name of the state/province/region. |
district | String | Optional | Name of the district or county. |
city | String | Optional | Name of the city. |
zip_code | String | Optional | ZIP code of the place. |
latitude | Float | Mandatory | Latitude of the place. |
longitude | Float | Mandatory | Longitude of the place. |
is_eu | Boolean | Mandatory | Is the country belongs to European Union? |
calling_code | String | Mandatory | Calling code of the country. |
country_tld | String | Mandatory | Top-level domain of the country. |
languages | String | Mandatory | Comma-separated list of the languages' codes, spoken in the country. |
country_flag | String | Mandatory | URL to get the country flag. |
geoname_id | Number | Mandatory | Geoname ID of the place from geonames.org |
isp | String | Mandatory | Name of the ISP holding the IP address. |
connection_type | String | Optional | Type of the connection, consuming the IP address. |
organization | String | Optional | Name of AS organization holding the IP address. |
asn | String | Optional | Autonomous system number of the autonomous system, to which IP address belongs to. |
currency.code | String | Mandatory | Currency code (ISO 4217). |
currency.name | String | Mandatory | Currency name (ISO 4217). |
currency.symbol | String | Mandatory | Currency symbol. |
time_zone.name | String | Mandatory | Name (ISO 8601) of the time zone. |
time_zone.offset | Number | Mandatory | Time zone offset from UTC. |
timezone.current_time | String | Mandatory | Current time in 'yyyy-MM-dd HH:mm:ss.SSS+ZZZ' format. |
timezone.current_time_unix | Float | Mandatory | Current time in seconds since 1970. |
timezone.is_dst | Boolean | Mandatory | Is the time zone in daylight savings? |
timezone.dst_savings | Number | Mandatory | Total daylight savings. |
security.threat_score | Number | Mandatory | IP address's threat score. It ranges from 0 (lowest threat) to 100 (highest threat). |
security.is_tor | Boolean | Mandatory | Indicates if the IP address is being consumed on a Tor endpoint. |
security.is_proxy | Boolean | Mandatory | Indicates if the IP address belongs to a proxy network. |
security.proxy_type | String | Optional | Type of the proxy network if the IP address belongs to a proxy network. |
security.is_anonymous | Boolean | Mandatory | Indicates if the IP address is being used anonymously. |
security.is_known_attacker | Boolean | Mandatory | Indicates if the IP address is enlisted as an attacking IP address. |
security.is_cloud_provider | Boolean | Mandatory | Indicates if the IP address belongs to a cloud provider (computing infrastructure providers). |
user_agent.userAgentString | String | Mandatory | User-Agent string passed along with the query in the User-Agent header. |
user_agent.name | String | Mandatory | User-Agent Name. |
user_agent.type | String | Mandatory | User-Agent Class. |
user_agent.version | String | Mandatory | User-Agent Version. |
user_agent.versionMajor | String | Mandatory | User-Agent Version Major. |
user_agent.device.name | String | Mandatory | Device Name. |
user_agent.device.type | String | Mandatory | Device Type. |
user_agent.device.brand | String | Mandatory | Device Brand. |
user_agent.device.CPU | String | Mandatory | Device CPU Model. |
user_agent.engine.name | String | Mandatory | Layout Engine Name. |
user_agent.engine.type | String | Mandatory | Layout Engine Class. |
user_agent.engine.version | String | Mandatory | Layout Engine Version. |
user_agent.engine.versionMajor | String | Mandatory | Layout Engine Version Major. |
user_agent.operatingSystem.name | String | Mandatory | Operating System Name. |
user_agent.operatingSystem.type | String | Mandatory | Operating System Class. |
user_agent.operatingSystem.version | String | Mandatory | Operating System Version. |
user_agent.operatingSystem.versionMajor | String | Mandatory | Operating System Version Major. |
HTTP Status | Reasons |
---|---|
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. |
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# Get geolocation for an IPv6 address = 2001:4860:4860::1curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8'# 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 } } }curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=2001:4860:4860::1'
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# 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 } } }curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=dns.google.com'
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{ "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": "" } }curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY'
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# 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>curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&format=xml'
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:
# Get city information only{ "ip": "8.8.8.8", "city": "Mountain View" } # Get the country name and country code (ISO2) onlycurl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=city'{ "ip": "8.8.8.8", "country_code2": "US", "country_name": "United States", "country_name_official": "United States of America" } # Get time zone information onlycurl '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", "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 onlycurl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=time_zone'{ "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 informationcurl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo'{ "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 informationcurl '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", "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" }curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&excludes=continent_code'
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{ "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 } }curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=security'
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:
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{ "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 sourcescurl '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": "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 sourcescurl '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": "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" }curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=hostnameFallbackLive'
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{ "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": "??" } } }curl 'https://api.apifreaks.com/v1.0/geolocation/lookup?apiKey=API-KEY&ip=8.8.8.8&fields=geo&include=useragent'
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.
Service | Credits |
---|---|
Basic Geolocation Data | 1 Credit per successful request |
Geolocation + User-Agent Parsing | 2 Credits per successful request |
Geolocation + User-Agent Parsing | 2 Credits per successful request |
Geolocation + IP Hostname Details | 2 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.