IP2Location.io Bulk IP Geolocation API

Overview

IP2Location.io provides RESTful API allowing users to check IP address location in bulk. This API supports up to 1000 IPv4 and IPv6 addresses per query.

What data you can get:
Country, region, district, city, latitude & longitude, ZIP code, time zone, ASN, and proxy data.

This API endpoint requires a Starter, Plus or Security Plan to work.

Parameters

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

Name Description
key (required) API key.
format (optional) Format of the response message.
Valid value: json | csv

If unspecified, json format will be used for the response message.
fields (optional) Custom fields returned by the API endpoint.
Valid value: country_code | country_name | region_name | city_name | latitude | longitude | zip_code | time_zone | asn | as | is_proxy

You can specify multiple fields by separating them with comma (,). If unspecified, all fields will be returned.
(POST Body) (required) A list of IP address separated by new line or JSON encoded IP list.

API Endpoint

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

Query String
echo -e '1.1.1.1\n2.2.2.2' | curl -XPOST --data-binary @- "bulk.ip2location.io/?key=YOUR_API_KEY&format=json"
Response
{
    "1.1.1.1": {
        "country_code": "US",
        "country_name": "United States of America",
        "region_name": "California",
        "city_name": "San Jose",
        "latitude": 37.33939,
        "longitude": -121.89496,
        "zip_code": "95101",
        "time_zone": "America/Los_Angeles",
        "asn": "13335",
        "as": "CloudFlare Inc.",
        "is_proxy": false
    },
    "2.2.2.2": {
        "country_code": "FR",
        "country_name": "France",
        "region_name": "Auvergne-Rhone-Alpes",
        "city_name": "Lyon",
        "latitude": 45.748313,
        "longitude": 4.846578,
        "zip_code": "69998",
        "time_zone": "Europe/Paris",
        "asn": "3215",
        "as": "Orange S.A.",
        "is_proxy": false
    }
}
echo -e '1.1.1.1\n2.2.2.2' | curl -XPOST --data-binary @- "bulk.ip2location.io/?key=YOUR_API_KEY&format=csv"
Response
1.1.1.1,US,"United States of America",California,"San Jose",37.33939,-121.89496,95101,America/Los_Angeles,13335,"CloudFlare Inc.",0
2.2.2.2,FR,France,Auvergne-Rhone-Alpes,Lyon,45.748313,4.846578,69998,Europe/Paris,3215,"Orange S.A.",0

Response Format

The REST API returns the following fields and values.

Field Description
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.
is_proxy Whether is a public proxy or not

Error Object & Codes

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

{
    "error": {
		"error_code": 401,
		"error_message": "Invalid API key or insufficient query."
    }
}

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

Error Code Error Message
401 Invalid API key or insufficient query.
500 Internal server error.

Sample Codes

You can use the sample codes below for different applications.

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

curl_setopt($ch, CURLOPT_POSTFIELDS, '["1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"]');
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);
URL url = new URL ("https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);

String jsonInputString = "[\"1.1.1.1\", \"2.2.2.2\", \"3.3.3.3\", \"4.4.4.4\"]";
try(OutputStream os = con.getOutputStream()) {
	byte[] input = jsonInputString.getBytes("utf-8");
	os.write(input, 0, input.length);
}

try(BufferedReader br = new BufferedReader(
	new InputStreamReader(con.getInputStream(), "utf-8"))) {
		StringBuilder response = new StringBuilder();
		String responseLine = null;

		while ((responseLine = br.readLine()) != null) {
			response.append(responseLine.trim());
		}
	System.out.println(response.toString());
}

								
Dim httpClient As New System.Net.Http.HttpClient

Dim buffer = Encoding.UTF8.GetBytes("""[1.1.1.1"", ""2.2.2.2"", ""3.3.3.3"", ""4.4.4.4""]""")
Dim bytes = New ByteArrayContent(buffer)
bytes.Headers.ContentType = New Headers.MediaTypeHeaderValue("application/json")
Dim response As String = Await httpClient.PostAsync("https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json", bytes)
Console.WriteLine($"{response}")
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
	string json = "[\"1.1.1.1\", \"2.2.2.2\", \"3.3.3.3\", \"4.4.4.4\"]";
	streamWriter.Write(json);
}

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
    var result = streamReader.ReadToEnd();
}
import requests
data = '["1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"]'

x = requests.post('https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json', data = data)
print(x.text)
echo '["1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"]' | curl -XPOST --data-binary @- "bulk.ip2location.io/?key=YOUR_API_KEY&format=json"
require "httpx"

response = HTTPX.post("https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json", :json => ["1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"])
puts response
fetch("https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json",{
	headers: {
		'Accept': 'application/json',
		'Content-Type': 'application/json'
	},
	method: "POST",
	body: '["1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"]'
})
.then(function(res){ console.log(res) })
.catch(function(res){ console.log(res) })
package main

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

func main() {
	values := map[string]string["1.1.1.1","2.2.2.2","3.3.3.3","4.4.4.4"]
	jsonValue, _ := json.Marshal(values)
	myUrl := "https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json"
	resp, _ := http.Post(myUrl, "application/json", bytes.NewBuffer(jsonValue))
	defer resp.Body.Close()

	bodyBytes, _ := io.ReadAll(resp.Body)
	bodyStr := string(bodyBytes[:])
	fmt.Println(bodyStr)
}
extern crate curl;

use curl::http;

fn main(){
	let resp = http::handle()
		.post("https://bulk.ip2location.io/?key=YOUR_API_KEY&format=json", '["1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"]')
		.exec().unwrap();

	println!("code={}; headers={}; body={}",
	resp.get_code(), resp.get_headers(), resp.get_body());
}

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