Convert IP
This function allows you to convert a single IP address into its corresponding geolocation data using, see an example below:
import { ConvertIP } from '@ip2geo/sdk'
const ipAddress = '8.8.8.8'
const { data, success, message } = await ConvertIP({
ip: ipAddress
})converted = Ip2Geo.convert_ip(ip: '8.8.8.8')
# {
# 'success' => true,
# 'code' => 200,
# 'message' => 'Success',
# 'data' => { ... },
# '_req' => { 'reqId' => '...', 'resTime' => 123 }
# }import ip2geo
result = ip2geo.convert_ip(ip='8.8.8.8')
# {
# 'success': True,
# 'code': 200,
# 'message': 'Success',
# 'data': { ... },
# '_req': { 'reqId': '...', 'resTime': 123 }
# }<?php
use Ip2Geo\Ip2Geo;
$result = Ip2Geo::convertIp(ip: '8.8.8.8');
// [
// 'success' => true,
// 'code' => 200,
// 'message' => 'Success',
// 'data' => [ ... ],
// '_req' => ['reqId' => '...', 'resTime' => 123],
// ]Parameters
ipstringrequiredThe IPv4 or IPv6 address to convert.
Response
successbooleanWhether the request was successful.
messagestringResponse message describing the result.
codenumberHTTP status code.
dataIp | nullThe geolocation data for the IP address. See Ip Interface for details. It is null when the address has no geolocation data, with code 404 (private, reserved and unassigned addresses have none), or when the conversion failed. Either way the address counts toward your quota. Read more about IP Response Interface.
_reqobjectRequest metadata containing:
reqId: Unique request identifier.resTime: Response time in milliseconds.
Parameters
ipStringrequiredThe IPv4 or IPv6 address to convert.
Response
successBooleanWhether the request was successful.
messageStringResponse message describing the result.
codeIntegerHTTP status code.
dataHash | nilThe geolocation data for the IP address. See Ip Interface for details. It is nil when the address has no geolocation data, with code 404 (private, reserved and unassigned addresses have none), or when the conversion failed. Either way the address counts toward your quota. Read more about IP Response Interface.
_reqHashRequest metadata containing:
‘reqId’: Unique request identifier.‘resTime’: Response time in milliseconds.
Parameters
ipstrrequiredThe IPv4 or IPv6 address to convert.
Response
successboolWhether the request was successful.
messagestrResponse message describing the result.
codeintHTTP status code.
datadict | NoneThe geolocation data for the IP address. See Ip Interface for details. It is None when the address has no geolocation data, with code 404 (private, reserved and unassigned addresses have none), or when the conversion failed. Either way the address counts toward your quota. Read more about IP Response Interface.
_reqdictRequest metadata containing:
‘reqId’: Unique request identifier.‘resTime’: Response time in milliseconds.
Parameters
ipstringrequiredThe IPv4 or IPv6 address to convert.
Response
successboolWhether the request was successful.
messagestringResponse message describing the result.
codeintHTTP status code.
dataarray | nullThe geolocation data for the IP address. See Ip Interface for details. It is null when the address has no geolocation data, with code 404 (private, reserved and unassigned addresses have none), or when the conversion failed. Either way the address counts toward your quota. Read more about IP Response Interface.
_reqarrayRequest metadata containing:
‘reqId’: Unique request identifier.‘resTime’: Response time in milliseconds.