Skip to main content
This function allows you to convert a single IP address into its corresponding geolocation data using, see an example below:
You should authenticate/initialize Ip2Geo before using this method.
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

ip
string
required
The IPv4 or IPv6 address to convert.

Response

success
boolean
Whether the request was successful.
message
string
Response message describing the result.
code
number
HTTP status code.
data
Ip | null
The geolocation data for the IP address. See Ip Interface for details. Returns null if the conversion failed, read more about IP Response Interface.
_req
object
Request metadata containing:
  • reqId: Unique request identifier.
  • resTime: Response time in milliseconds.