IP2Location.io IP Geolocation API

Overview

IP2Location.io provides RESTful API allowing users to query for an enriched data set, such as country, region, district, city, latitude & longitude, ZIP code, time zone, ASN, ISP, domain, net speed, IDD code, area code, weather station data, MNC, MCC, mobile brand, elevation, usage type, address type, advertisement category and proxy data with an IP address. The REST API supports both IPv4 and IPv6 address lookup. The API requires an API key to function. If you do not have one, you may click on the below button to sign up for a Free Plan.

Get A Free API Key

Parameters

The REST API calling syntax. Please see the table below for the description of each parameter.

Name Description
key (required) API key.
ip (required) IP address (IPv4 or IPv6) for reverse IP location lookup purposes. If not present, the server IP address will be used for the location lookup.
format (optional) Format of the response message.
Valid value: json | xml

If unspecified, json format will be used for the response message.
lang (optional) Translation information(ISO639-1). The translation is only applicable for continent, country, region and city name.
Valid value: ar | cs | da | de | en | es | et | fi | fr | ga | it | ja | ko | ms | nl | pt | ru | sv | tr | vi | zh-cn | zh-tw

You can only specify one language value for the returns.

Note: This parameter is only available for Plus and Security plan only.

API Endpoint

The IP2Location.io API supports json(default) and xml response formats. Please find the sample response of all plans below.

Query String
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=json    
Response
{
	"ip":"8.8.8.8",
	"country_code":"US",
	"country_name":"United States of America",
	"region_name":"California",
	"city_name":"Mountain View",
	"latitude":37.405992,
	"longitude":-122.078515,
	"zip_code":"94043",
	"time_zone":"-07:00",
	"asn":"15169",
	"as":"Google LLC",
	"is_proxy":false
}
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=xml    
Response
<result>
	<ip>8.8.8.8</ip>
	<country_code>US</country_code>
	<country_name>United States of America</country_name>
	<region_name>California</region_name>
	<city_name>Mountain View</city_name>
	<latitude>37.405992</latitude>
	<longitude>-122.078515</longitude>
	<zip_code>94043</zip_code>
	<time_zone>-07:00</time_zone>
	<asn>15169</asn>
	<as>Google LLC</as>
	<is_proxy>false</is_proxy>
</result>
Query String
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=json    
Response
{
	"ip":"8.8.8.8",
	"country_code":"US",
	"country_name":"United States of America",
	"region_name":"California",
	"city_name":"Mountain View",
	"latitude":37.405992,
	"longitude":-122.078515,
	"zip_code":"94043",
	"time_zone":"-07:00",
	"asn":"15169",
	"as":"Google LLC",
	"isp":"Google LLC",
	"domain":"google.com",
	"net_speed":"T1",
	"idd_code":"1",
	"area_code":"650",
	"weather_station_code":"USCA0746",
	"weather_station_name":"Mountain View",
	"elevation":32,
	"usage_type":"DCH",
	"is_proxy":false
}
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=xml    
Response
<result>
	<ip>8.8.8.8</ip>
	<country_code>US</country_code>
	<country_name>United States of America</country_name>
	<region_name>California</region_name>
	<city_name>Mountain View</city_name>
	<latitude>37.405992</latitude>
	<longitude>-122.078515</longitude>
	<zip_code>94043</zip_code>
	<time_zone>-07:00</time_zone>
	<asn>15169</asn>
	<as>Google LLC</as>
	<isp>Google LLC</isp>
	<domain>google.com</domain>
	<net_speed>T1</net_speed>
	<idd_code>1</idd_code>
	<area_code>650</area_code>
	<weather_station_code>USCA0746</weather_station_code>
	<weather_station_name>Mountain View</weather_station_name>
	<elevation>32</elevation>
	<usage_type>DCH</usage_type>
	<is_proxy>false</is_proxy>
</result>
Query String
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=json&lang=ko    
Response
{
	"ip":"8.8.8.8",
	"country_code":"US",
	"country_name":"United States of America",
	"region_name":"California",
	"city_name":"Mountain View",
	"latitude":37.405992,
	"longitude":-122.078515,
	"zip_code":"94043",
	"time_zone":"-07:00",
	"asn":"15169",
	"as":"Google LLC",
	"isp":"Google LLC",
	"domain":"google.com",
	"net_speed":"T1",
	"idd_code":"1",
	"area_code":"650",
	"weather_station_code":"USCA0746",
	"weather_station_name":"Mountain View",
	"mcc":"-",
	"mnc":"-",
	"mobile_brand":"-",
	"elevation":32,
	"usage_type":"DCH",
	"address_type":"Anycast",
	"continent":{
		"name":"North America",
		"code":"NA",
		"hemisphere":["north","west"],
		"translation":{
			"lang":"ko",
			"value":"북아메리카"
		}
	},
	"country":{
		"name":"United States of America",
		"alpha3_code":"USA",
		"numeric_code":840,
		"demonym":"Americans",
		"flag":"https://cdn.ip2location.io/assets/img/flags/us.png",
		"capital":"Washington, D.C.",
		"total_area":9826675,
		"population":331002651,
		"currency":{
			"code":"USD",
			"name":"United States Dollar",
			"symbol":"$"
		},
		"language":{
			"code":"EN",
			"name":"English"
		},
		"tld":"us",
		"translation":{
			"lang":"ko",
			"value":"미국"
		}
	},
	"region":{
		"name":"California",
		"code":"US-CA",
		"translation":{
			"lang":"ko",
			"value":"캘리포니아주"
		}
	},
	"city":{
		"name":"Mountain View",
		"translation":{
			"lang":null,
			"value":null
		}
	},
	"time_zone_info":{
		"olson":"America/Los_Angeles",
		"current_time":"2022-04-18T23:13:19-07:00",
		"gmt_offset":-25200,"is_dst":true,
		"sunrise":"06:27",
		"sunset":"19:47"
	},
	"geotargeting":{
		"metro":"807"
	},
	"is_proxy":false
}
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=xml&lang=ko    
Response
<result>
	<ip>8.8.8.8</ip>
	<country_code>US</country_code>
	<country_name>United States of America</country_name>
	<region_name>California</region_name>
	<city_name>Mountain View</city_name>
	<latitude>37.405992</latitude>
	<longitude>-122.078515</longitude>
	<zip_code>94043</zip_code>
	<time_zone>-07:00</time_zone>
	<asn>15169</asn>
	<as>Google LLC</as>
	<isp>Google LLC</isp>
	<domain>google.com</domain>
	<net_speed>T1</net_speed>
	<idd_code>1</idd_code>
	<area_code>650</area_code>
	<weather_station_code>USCA0746</weather_station_code>
	<weather_station_name>Mountain View</weather_station_name>
	<mcc>-</mcc>
	<mnc>-</mnc>
	<mobile_brand>-</mobile_brand>
	<elevation>32</elevation>
	<usage_type>DCH</usage_type>
	<address_type>Anycast</address_type>
	<continent>
		<name>North America</name>
		<code>NA</code>
		<hemisphere>
			<item>north</item>
			<item>west</item>
		</hemisphere>
		<translation>
			<lang>ko</lang>
			<value>북아메리카</value>
		</translation>
	</continent>
	<country>
		<name>United States of America</name>
		<alpha3_code>USA</alpha3_code>
		<numeric_code>840</numeric_code>
		<demonym>Americans</demonym>
		<flag>https://cdn.ip2location.io/assets/img/flags/us.png</flag>
		<capital>Washington, D.C.</capital>
		<total_area>9826675</total_area>
		<population>331002651</population>
		<currency>
			<code>USD</code>
			<name>United States Dollar</name>
			<symbol>$</symbol>
		</currency>
		<language>
			<code>EN</code>
			<name>English</name>
		</language>
		<tld>us</tld>
		<translation>
			<lang>ko</lang>
			<value>미국</value>
		</translation>
	</country>
	<region>
		<name>California</name>
		<code>US-CA</code>
		<translation>
			<lang>ko</lang>
			<value>캘리포니아주</value>
		</translation>
	</region>
	<city>
		<name>Mountain View</name>
		<translation>
			<lang/>
			<value/>
		</translation>
	</city>
	<time_zone_info>
		<olson>America/Los_Angeles</olson>
		<current_time>2022-04-18T23:17:31-07:00</current_time>
		<gmt_offset>-25200</gmt_offset>
		<is_dst>true</is_dst>
		<sunrise>06:27</sunrise>
		<sunset>19:47</sunset>
	</time_zone_info>
	<geotargeting>
		<metro>807</metro>
	</geotargeting>
	<is_proxy>false</is_proxy>
</result>
Query String
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=json&lang=ko    
Response
{
	"ip":"8.8.8.8",
	"country_code":"US",
	"country_name":"United States of America",
	"region_name":"California",
	"city_name":"Mountain View",
	"latitude":37.405992,
	"longitude":-122.078515,
	"zip_code":"94043",
	"time_zone":"-07:00",
	"asn":"15169",
	"as":"Google LLC",
	"isp":"Google LLC",
	"domain":"google.com",
	"net_speed":"T1",
	"idd_code":"1",
	"area_code":"650",
	"weather_station_code":"USCA0746",
	"weather_station_name":"Mountain View",
	"mcc":"-",
	"mnc":"-",
	"mobile_brand":"-",
	"elevation":32,
	"usage_type":"DCH",
	"address_type":"Anycast",
	"continent":{
		"name":"North America",
		"code":"NA",
		"hemisphere":["north","west"],
		"translation":{
			"lang":"ko",
			"value":"북아메리카"
		}
	},
	"country":{
		"name":"United States of America",
		"alpha3_code":"USA",
		"numeric_code":840,
		"demonym":"Americans",
		"flag":"https://cdn.ip2location.io/assets/img/flags/us.png",
		"capital":"Washington, D.C.",
		"total_area":9826675,
		"population":331002651,
		"currency":{
			"code":"USD",
			"name":"United States Dollar",
			"symbol":"$"
		},
		"language":{
			"code":"EN",
			"name":"English"
		},
		"tld":"us",
		"translation":{
			"lang":"ko",
			"value":"미국"
		}
	},
	"region":{
		"name":"California",
		"code":"US-CA",
		"translation":{
			"lang":"ko",
			"value":"캘리포니아주"
		}
	},
	"city":{
		"name":"Mountain View",
		"translation":{
			"lang":null,
			"value":null
		}
	},
	"time_zone_info":{
		"olson":"America/Los_Angeles",
		"current_time":"2022-04-18T23:41:57-07:00",
		"gmt_offset":-25200,
		"is_dst":true,
		"sunrise":"06:27",
		"sunset":"19:47"
	},
	"geotargeting":{
		"metro":"807"
	},
	"ads_category":"IAB19",
	"ads_category_name":"Technology & Computing",
	"district":"San Diego County",
	"is_proxy":false,
	"proxy":{
		"last_seen":18,
		"proxy_type":"DCH",
		"threat":"-",
		"provider":"-"
	}
}
https://api.ip2location.io/?key={YOUR_API_KEY}&ip=8.8.8.8&format=xml&lang=ko    
Response
<result>
	<ip>8.8.8.8</ip>
	<country_code>US</country_code>
	<country_name>United States of America</country_name>
	<region_name>California</region_name>
	<city_name>Mountain View</city_name>
	<latitude>37.405992</latitude>
	<longitude>-122.078515</longitude>
	<zip_code>94043</zip_code>
	<time_zone>-07:00</time_zone>
	<asn>15169</asn>
	<as>Google LLC</as>
	<isp>Google LLC</isp>
	<domain>google.com</domain>
	<net_speed>T1</net_speed>
	<idd_code>1</idd_code>
	<area_code>650</area_code>
	<weather_station_code>USCA0746</weather_station_code>
	<weather_station_name>Mountain View</weather_station_name>
	<mcc>-</mcc>
	<mnc>-</mnc>
	<mobile_brand>-</mobile_brand>
	<elevation>32</elevation>
	<usage_type>DCH</usage_type>
	<address_type>Anycast</address_type>
	<continent>
		<name>North America</name>
		<code>NA</code>
		<hemisphere>
			<item>north</item>
			<item>west</item>
		</hemisphere>
		<translation>
			<lang>ko</lang>
			<value>북아메리카</value>
		</translation>
	</continent>
	<country>
		<name>United States of America</name>
		<alpha3_code>USA</alpha3_code>
		<numeric_code>840</numeric_code>
		<demonym>Americans</demonym>
		<flag>https://cdn.ip2location.io/assets/img/flags/us.png</flag>
		<capital>Washington, D.C.</capital>
		<total_area>9826675</total_area>
		<population>331002651</population>
		<currency>
			<code>USD</code>
			<name>United States Dollar</name>
			<symbol>$</symbol>
		</currency>
		<language>
			<code>EN</code>
			<name>English</name>
		</language>
		<tld>us</tld>
		<translation>
			<lang>ko</lang>
			<value>미국</value>
		</translation>
	</country>
	<region>
		<name>California</name>
		<code>US-CA</code>
		<translation>
			<lang>ko</lang>
			<value>캘리포니아주</value>
		</translation>
	</region>
	<city>
		<name>Mountain View</name>
		<translation>
			<lang/>
			<value/>
		</translation>
	</city>
	<time_zone_info>
		<olson>America/Los_Angeles</olson>
		<current_time>2022-04-18T23:45:48-07:00</current_time>
		<gmt_offset>-25200</gmt_offset>
		<is_dst>true</is_dst>
		<sunrise>06:27</sunrise>
		<sunset>19:47</sunset>
	</time_zone_info>
	<geotargeting>
		<metro>807</metro>
	</geotargeting>
	<ads_category>IAB19</ads_category>
	<ads_category_name>Technology & Computing</ads_category_name>
	<district>San Diego County</district>
	<is_proxy>false</is_proxy>
	<proxy>
		<last_seen>18</last_seen>
		<proxy_type>DCH</proxy_type>
		<threat>-</threat>
		<provider>-</provider>
	</proxy>
</result>

Don't have a free account? .

Response Format

The REST API returns the following fields and values.

Field Description
ip IP address
country_code Two-character country code based on ISO 3166.
country_name Country name based on ISO 3166.
region_name Region or state name.
city_name City name.
latitude City latitude. Defaults to capital city latitude if city is unknown.
longitude City longitude. Defaults to capital city longitude if city is unknown.
zip_code ZIP/Postal code.
time_zone UTC time zone (with DST supported).
asn Autonomous system number (ASN).
as Autonomous system (AS) name.
isp Internet Service Provider or company's name.
domain Internet domain name associated with IP address range.
net_speed Internet connection type.
DIAL = dial-up, DSL = broadband/cable/fiber/mobile, COMP = company/T1
idd_code The IDD prefix to call the city from another country.
area_code A varying length number assigned to geographic areas for calls between cities.
weather_station_code The special code to identify the nearest weather observation station.
weather_station_name The name of the nearest weather observation station.
mcc Mobile Country Codes (MCC) as defined in ITU E.212 for use in identifying mobile stations in wireless telephone networks, particularly GSM and UMTS networks.
mnc Mobile Network Code (MNC) is used in combination with a Mobile Country Code (MCC) to uniquely identify a mobile phone operator or carrier.
mobile_brand Commercial brand associated with the mobile carrier.
elevation Average height of city above sea level in meters (m).
usage_type Usage type classification of ISP or company
(COM) Commercial
(ORG) Organization
(GOV) Government
(MIL) Military
(EDU) University/College/School
(LIB) Library
(CDN) Content Delivery Network
(ISP) Fixed Line ISP
(MOB) Mobile ISP
(DCH) Data Center/Web Hosting/Transit
(SES) Search Engine Spider
(RSV) Reserved
address_type IP address types as defined in Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6).
(A) Anycast - One to the closest
(U) Unicast - One to one
(M) Multicast - One to multiple
(B) Broadcast - One to all
ads_category The domain category code based on IAB Tech Lab Content Taxonomy.
ads_category_name The domain category based on IAB Tech Lab Content Taxonomy. These categories are comprised of Tier-1 and Tier-2 (if available) level categories widely used in services like advertising, Internet security and filtering appliances.
district District or county name.
continent.name Continent name.
continent.code Two-character continent code.
continent.hemisphere The hemisphere of where the country located. The data in array format with first item indicates (north/south) hemisphere and second item indicates (east/west) hemisphere information.
continent.translation Translation data based on the given lang code.
country.name Country name based on ISO 3166.
country.alpha3_code Three-character country code based on ISO 3166.
country.numeric_code Three-character country numeric code based on ISO 3166.
country.demonym Native of the country
country.flag URL of the country flag image.
country.capital Capital of the country.
country.total_area Total area in km2.
country.population Population of the country.
country.currency Currency of the country
country.language Language of the country
country.tld Country-Code Top-Level Domain.
country.translation Translation data based on the given lang code.
region.name Region or state name.
region.code ISO3166-2 code.
region.translation Translation data based on the given lang code.
city.name City name.
city.translation Translation data based on the given lang code.
time_zone_info.olson Time zone in Olson format.
time_zone_info.current_time Current time in ISO 8601 format.
time_zone_info.gmt_offset GMT offset value in seconds.
time_zone_info.is_dst Indicate if the time zone value is in DST.
time_zone_info.sunrise Time of sunrise. (hh:mm format in local time, i.e, 07:47)
time_zone_info.sunset Time of sunset. (hh:mm format in local time, i.e 19:50)
geotargeting.metro Metro code based on zip/postal code.
is_proxy Whether is a proxy or not
proxy.last_seen Proxy last seen in days.
proxy.proxy_type Type of proxy.
(VPN) Anonymizing VPN services
(TOR) Tor Exit Nodes
(DCH) Hosting Provider, Data Center or Content Delivery Network
(PUB) Public Proxies
(WEB) Web Proxies
(SES) Search Engine Robots
(RES) Residential proxies
proxy.threat Security threat reported.
(SPAM) Email and forum spammers
(SCANNER) Network security scanners
(BOTNET) Malware infected devices
proxy.provider Name of VPN provider if available.

Error Object & Codes

An Error object will be returned for any error encountered. For example:

{
    "error": {
        "error_code": 10001,
        "error_message": "Invalid IP address."
    }
}

Below is the complete list of the error code and message returned by the IP2Location.io API.

Error Code Error Message
10000 Invalid API key or insufficient credit.
10001 Invalid IP address.
10002 Internal server error.
10003 Invalid language code.
10004 Translation is not available with your plan.

Sample Codes

You can use the sample codes below for different applications.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.ip2location.io/?' . http_build_query([
	'ip'      => '8.8.8.8',
	'key'     => 'YOUR_API_KEY',
	'format'  => 'json',
]));

curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);

$response = curl_exec($ch);

var_dump($response);
try (java.util.Scanner s = new java.util.Scanner(new java.net.URL("https://api.ip2location.io/?key=YOUR_API_KEY&ip=8.8.8.8&format=json").openStream(), "UTF-8").useDelimiter("\\A")) {
	System.out.println(s.next());
} catch (java.io.IOException e) {
	e.printStackTrace();
}
Dim httpClient As New System.Net.Http.HttpClient
Dim response As String = Await httpClient.GetStringAsync("https://api.ip2location.io/?key=YOUR_API_KEY&ip=8.8.8.8&format=json")
Console.WriteLine($"{response}")
var httpClient = new HttpClient();
var response = await httpClient.GetStringAsync("https://api.ip2location.io/?key=YOUR_API_KEY&ip=8.8.8.8&format=json");
Console.WriteLine($"{response}");
import requests

payload = {'key': 'YOUR_API_KEY', 'ip': '8.8.8.8', 'format': 'json'}
api_result = requests.get('https://api.ip2location.io/', params=payload)
print(api_result.text)
curl -s "https://api.ip2location.io/?key=YOUR_API_KEY&ip=8.8.8.8&format=json"

require "net/http"

response = Net::HTTP.get(URI("https://api.ip2location.io/?key=YOUR_API_KEY&ip=8.8.8.8&format=json"))
puts response