IP2Location.io IP Geolocation API

Overview

IP2Location.io provides RESTful API allowing users to check IP address location in real time. The REST API supports both IPv4 and IPv6 address lookup.

What data you can get:
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 API does not requires any API key to work, but it has limitation. It is free for up to 500 queries daily. If you need more queries, you can sign up for a Free Plan and get an API key with just a few clicks!

Get A Free API Key

Rate Limiting

An API rate limit refers to the maximum number of API calls that can be made within a specific time period. IP2Location.io allows you to perform up to 500 queries per day without the need to sign up for an API key (keyless). Once this limit is reached, any additional API calls will fail until the time period resets at 00:00 UTC daily.

If you wish to remove the daily rate limit and perform more than 500 queries per day, you can get started by signing up for our to obtain an API key. It's free, and with this plan, you are able to make up to 30,000 queries per month.

Below is the command to perform the keyless query:

https://api.ip2location.io/?ip=8.8.8.8

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":"-",
		"is_vpn": false,
		"is_tor": false,
		"is_data_center": true,
		"is_public_proxy": false,
		"is_web_proxy": false,
		"is_web_crawler": false,
		"is_residential_proxy": false,
		"is_consumer_privacy_network": false,
		"is_enterprise_private_network": false,
		"is_spammer": false,
		"is_scanner": false,
		"is_botnet": 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: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>
		<is_vpn>false</is_vpn>
		<is_tor>false</is_tor>
		<is_data_center>true</is_data_center>
		<is_public_proxy>false</is_public_proxy>
		<is_web_proxy>false</is_web_proxy>
		<is_web_crawler>false</is_web_crawler>
		<is_residential_proxy>false</is_residential_proxy>
		<is_consumer_privacy_network>false</is_consumer_privacy_network>
		<is_enterprise_private_network>false</is_enterprise_private_network>
		<is_spammer>false</is_spammer>
		<is_scanner>false</is_scanner>
		<is_botnet>false</is_botnet>
	</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 = corporate, T1 = data center/transit, SAT = satellite
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) Virtual Private Networks
(TOR) Tor Exit Nodes
(DCH) Hosting Providers, Data Centers or Content Delivery Networks
(PUB) Public Proxies
(WEB) Web Proxies
(SES) Search Engine Robots
(RES) Residential Proxies
(CPN) Consumer Privacy Networks
(EPN) Enterprise Private Networks
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.
proxy.is_vpn Anonymizing VPN services.
proxy.is_tor Tor Exit Nodes.
proxy.is_data_center Hosting Provider, Data Center or Content Delivery Network.
proxy.is_public_proxy Public Proxies.
proxy.is_web_proxy Web Proxies.
proxy.is_web_crawler Search Engine Robots.
proxy.is_residential_proxy Residential proxies.
proxy.is_spammer Email and forum spammers.
proxy.is_scanner Network security scanners.
proxy.is_botnet Malware infected devices.
proxy.is_consumer_privacy_network Consumer Privacy Networks.
proxy.is_enterprise_private_network Enterprise Private Networks.

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 query.
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
var https = require("https");

let url = "https://api.ip2location.io/?key=YOUR_API_KEY&ip=8.8.8.8&format=json";

let response = "";
let req = https.get(url, function (res) {
	res.on("data", (chunk) => (response = response + chunk));
	res.on("end", function () {
		console.log(response);
	});
});
package main

import (
	"net/http"
	"fmt"
	"io"
)

func main() {
	myUrl := "https://api.ip2location.io/?key=YOUR_API_KEY&ip=8.8.8.8&format=json"
	resp, _ := http.Get(myUrl)
	defer resp.Body.Close()

	bodyBytes, _ := io.ReadAll(resp.Body)
	bodyStr := string(bodyBytes[:])
	fmt.Println(bodyStr)
}
use reqwest;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let url = format!(
								"https://api.ip2location.io/?key={}&ip={}&format=json",
								"YOUR_API_KEY", "8.8.8.8"
				  );
	let b = reqwest::get(url)
				  .get(url)
				  .send()
				  .await
				  .expect("failed to get response")
				  .text()
				  .await
				  .expect("failed to get payload");

	println!("Got {:?}", b);
	Ok(())
}

Unlock Location Insights For Free

Empower your applications with accurate IP geolocation information now.

Try It for Free
IP2Location.io IP Geolocation API
Dive in and experience accurate IP geolocation API for FREE!
Get FREE API