Bulk Convert IP's
This function allows you to convert multiple IP addresses in a single request, making it efficient for batch processing. You can provide an array of IP addresses, and the function will return their corresponding geolocation data.
import { ConvertIPs } from '@ip2geo/sdk'
const ipAddresses = [
'8.8.8.8',
'8.8.4.4',
'1.1.1.1',
'9.9.9.9',
'4.4.4.4',
'3.3.3.3'
]
const { data, success, message } = await ConvertIPs({
ips: ipAddresses
})ip_addresses = [
'8.8.8.8',
'8.8.4.4',
'1.1.1.1',
'9.9.9.9',
'4.4.4.4',
'3.3.3.3'
]
result = Ip2Geo.convert_ips(ips: ip_addresses)
# {
# 'success' => true,
# 'code' => 200,
# 'message' => 'Success',
# 'data' => [
# { 'ip' => '8.8.8.8', 'conversion' => { ... } },
# { 'ip' => '8.8.4.4', 'conversion' => { ... } },
# ...
# ],
# '_req' => { 'reqId' => '...', 'resTime' => 123 }
# }import ip2geo
ip_addresses = [
'8.8.8.8',
'8.8.4.4',
'1.1.1.1',
'9.9.9.9',
'4.4.4.4',
'3.3.3.3',
]
result = ip2geo.convert_ips(ips=ip_addresses)
# {
# 'success': True,
# 'code': 200,
# 'message': 'Success',
# 'data': [
# { 'ip': '8.8.8.8', 'conversion': { ... } },
# { 'ip': '8.8.4.4', 'conversion': { ... } },
# ...
# ],
# '_req': { 'reqId': '...', 'resTime': 123 }
# }<?php
use Ip2Geo\Ip2Geo;
$ipAddresses = [
'8.8.8.8',
'8.8.4.4',
'1.1.1.1',
'9.9.9.9',
'4.4.4.4',
'3.3.3.3',
];
$result = Ip2Geo::convertIps(ips: $ipAddresses);
// [
// 'success' => true,
// 'code' => 200,
// 'message' => 'Success',
// 'data' => [
// ['ip' => '8.8.8.8', 'conversion' => [ ... ]],
// ['ip' => '8.8.4.4', 'conversion' => [ ... ]],
// ...
// ],
// '_req' => ['reqId' => '...', 'resTime' => 123],
// ]Parameters
ipsArray<string>requiredAn array of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request.
Response
successbooleanWhether the request was successful.
messagestringResponse message describing the result.
codenumberHTTP status code.
dataArray<{ ip: string, conversion: Ip | null }>An array of conversion results. Each item contains:
ip: The IP address that was converted.conversion: The geolocation data for the IP (see Ip Interface). It isnullwhen the address is invalid, has no geolocation data (private, reserved and unassigned addresses have none) or failed; every address counts toward your quota. See the Response Interface.
_reqobjectRequest metadata containing:
reqId: Unique request identifier.resTime: Response time in milliseconds.
Parameters
ipsArray<String>requiredAn array of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request.
Response
successBooleanWhether the request was successful.
messageStringResponse message describing the result.
codeIntegerHTTP status code.
dataArray<Hash>An array of conversion results. Each item contains:
‘ip’: The IP address that was converted.‘conversion’: The geolocation data for the IP (see Ip Interface). It isnilwhen the address is invalid, has no geolocation data (private, reserved and unassigned addresses have none) or failed; every address counts toward your quota. See the Response Interface.
_reqHashRequest metadata containing:
‘reqId’: Unique request identifier.‘resTime’: Response time in milliseconds.
Parameters
ipslist[str]requiredA list of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request.
Response
successboolWhether the request was successful.
messagestrResponse message describing the result.
codeintHTTP status code.
datalist[dict]A list of conversion results. Each item contains:
‘ip’: The IP address that was converted.‘conversion’: The geolocation data for the IP (see Ip Interface). It isNonewhen the address is invalid, has no geolocation data (private, reserved and unassigned addresses have none) or failed; every address counts toward your quota. See the Response Interface.
_reqdictRequest metadata containing:
‘reqId’: Unique request identifier.‘resTime’: Response time in milliseconds.
Parameters
ipsarrayrequiredAn array of IPv4 or IPv6 addresses to convert. Maximum 5000 IPs per request.
Response
successboolWhether the request was successful.
messagestringResponse message describing the result.
codeintHTTP status code.
dataarrayAn array of conversion results. Each item contains:
‘ip’: The IP address that was converted.‘conversion’: The geolocation data for the IP (see Ip Interface). It isnullwhen the address is invalid, has no geolocation data (private, reserved and unassigned addresses have none) or failed; every address counts toward your quota. See the Response Interface.
_reqarrayRequest metadata containing:
‘reqId’: Unique request identifier.‘resTime’: Response time in milliseconds.