API - Integration
Bulk Convert IP's
This http method allows you to convert multiple IP addresses into their corresponding geolocation data.
POST
/
convert
Ip2Geo - Bulk Convert IPs
curl --request POST \
--url https://api.ip2geo.dev/convert \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"ips": [
"<string>"
]
}
'import requests
url = "https://api.ip2geo.dev/convert"
payload = { "ips": ["<string>"] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ips: ['<string>']})
};
fetch('https://api.ip2geo.dev/convert', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ip2geo.dev/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ips' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ip2geo.dev/convert"
payload := strings.NewReader("{\n \"ips\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ip2geo.dev/convert")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ips\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ip2geo.dev/convert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ips\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"code": 123,
"data": [
{
"ip": "<string>",
"conversion": {
"ip": "<string>",
"is_eu": true,
"continent": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"phone_code": "<string>",
"capital": "<string>",
"tld": "<string>",
"subdivision": {
"name": "<string>",
"code": "<string>"
},
"city": {
"name": "<string>",
"geoname_id": 123,
"latitude": 123,
"longitude": 123,
"accuracy_radius": 123,
"metro_code": 123,
"postal_code": "<string>",
"timezone": {
"name": "<string>",
"time_now": "<string>"
}
},
"flag": {
"img": "<string>",
"emoji": "<string>",
"emoji_unicode": "<string>"
},
"currency": {
"name": "<string>",
"code": "<string>",
"symbol": "<string>"
}
}
},
"registered_country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123
},
"asn": {
"number": 123,
"name": "<string>"
},
"completion_time": {
"miliseconds": 123,
"seconds": 123
}
}
}
],
"_req": {
"reqId": "<string>",
"resTime": 123
}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": null
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": null
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": null
}This method can convert up to 5000 IP addresses in a single request. If you need to convert more than 5000 IPs, consider splitting your requests into smaller batches to avoid exceeding this limit.
Authorizations
Use your Ip2Geo secret key (i2g_sk_...) for server-side requests, or public key (i2g_pk_...) for client-side requests. Example: x-api-key: i2g_sk_abc123.
Body
application/json
Array of IPv4 or IPv6 addresses to lookup.
Maximum array length:
5000Was this page helpful?
Previous
Get ConversionThis http method allows you to retrieve a single conversion by its unique identifier.
Next
⌘I
Ip2Geo - Bulk Convert IPs
curl --request POST \
--url https://api.ip2geo.dev/convert \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"ips": [
"<string>"
]
}
'import requests
url = "https://api.ip2geo.dev/convert"
payload = { "ips": ["<string>"] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ips: ['<string>']})
};
fetch('https://api.ip2geo.dev/convert', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ip2geo.dev/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ips' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ip2geo.dev/convert"
payload := strings.NewReader("{\n \"ips\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ip2geo.dev/convert")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ips\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ip2geo.dev/convert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ips\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"code": 123,
"data": [
{
"ip": "<string>",
"conversion": {
"ip": "<string>",
"is_eu": true,
"continent": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123,
"phone_code": "<string>",
"capital": "<string>",
"tld": "<string>",
"subdivision": {
"name": "<string>",
"code": "<string>"
},
"city": {
"name": "<string>",
"geoname_id": 123,
"latitude": 123,
"longitude": 123,
"accuracy_radius": 123,
"metro_code": 123,
"postal_code": "<string>",
"timezone": {
"name": "<string>",
"time_now": "<string>"
}
},
"flag": {
"img": "<string>",
"emoji": "<string>",
"emoji_unicode": "<string>"
},
"currency": {
"name": "<string>",
"code": "<string>",
"symbol": "<string>"
}
}
},
"registered_country": {
"name": "<string>",
"code": "<string>",
"geoname_id": 123
},
"asn": {
"number": 123,
"name": "<string>"
},
"completion_time": {
"miliseconds": 123,
"seconds": 123
}
}
}
],
"_req": {
"reqId": "<string>",
"resTime": 123
}
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": null
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": null
}{
"success": false,
"message": "<string>",
"code": 123,
"_req": {
"reqId": "<string>",
"resTime": 123
},
"data": null
}