IP Geolocation

The /ip_geolocation endpoint retrieves the geolocation information of any IP address, whether it be IPv4, or IPv6.

Method: GET

To retrieve the info of any IP address just send a GET request to the /ip_geolocation endpoint with the ip parameter, and the authorization header.

Parameters

This endpoints accepts only one parameter, i.e., ip:

  • ip: This is the IP address for which the geolocation data should be returned. If not set, it defaults to the client IP address.

Responses

The success response would be like this, where data contains the various information, about the network and location of IP address.

{
  "status":"success",
  "data": {
    "ip":"8.8.8.8",
    "ip_type":"IPv4", 
    "city": {
      "name":"Mountain View"
    },
    "continent":{ 
      "code":"NA",
      "name":"North America"
    },
    "country":{
      "is_eu":false,
      "iso_code":"US",
      "name":"United States"
    },
    "location":{
      "latitude":37.4223,
      "longitude":-122.085,
      "time_zone":"",
      "weather_code":"USCA0746"
    },
    "subdivisions":[
      {
        "name":"California",
        "iso_code":"CA"
      },
      {
        "name":"Santa Clara"
      }
    ],
    "metadata":{
      "organization":"Level 3",
      "isp":"Google LLC",
      "user_type":"hosting"
    }
  },
  "message":"IP geolocation data retrieved successfully."
} 

And if some error occurs, like providing an invalid IP address, e.g. 999.999.999.999, the response would be like this:

{
  "status":"error",
  "error": {
    "code":"INVALID_IP",
    "message":"Invalid IP address provided.",
    "details":"Ensure the 'ip' query parameter is a valid IPv4 or IPv6 address."
  }
}

Notes

When ip parameter is not provided, the system will try to find the IP address, which may not always be correct.