Skip to content

ip.php

Module for managing IP addresses and network infrastructure: retrieving IP information, managing PTR records, tracking traffic, and working with subnets and VLANs.

API Methods

Method Action Description
get_client_ip get client IP Returns the current client's IP address
get_ip get IP information Returns full information about a specific IP address (network, mask, etc.)
get_ptr get PTR record Checks and returns the PTR record for the specified IP
get_traffic get traffic statistics Returns incoming and outgoing traffic statistics for an IP over a specified period
list_free_ip list free IPs Returns a list of available IP addresses for a specified location or subnet
set_main set main IP Sets the specified IP as the primary IP for the server interface
update_ptr update PTR record Updates the PTR record (reverse DNS) for the specified IP

ip/get_client_ip

Returns the current client's IP address

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_client_ip
- - - No other parameters

Example Request

curl -s "https://api.hostkey.com/ip.php" -X POST \
--data "action=get_client_ip"
Example of a successful response
{
"result": "OK",
"data": {
  "ip": "192.168.1.100"
}
}
Failure response
{
"code": -1,
"message": "authentication required"
}

ip/get_ip

Returns full information about a specific IP address (network, mask, etc.)

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_ip
token string Authorization token
ip string IP address to query
full boolean Include full data in the response (data wrapper)

Example Request

curl -s "https://api.hostkey.com/ip.php" -X POST \
--data "action=get_ip" \
--data "token=HOSTKEY_TOKEN" \
--data "ip=VALUE"
Example of a successful response
{
"result": "OK",
"module": "ip",
"action": "get_ip",
"data": {
  "ip": "192.168.1.10",
  "network": "192.168.1.0",
  "netmask": "255.255.255.0",
  "location": "AMS",
  "status": "active"
}
}
Failure response
{
"code": -1,
"message": "malformed IP=192.168.1.10 for token abc123",
"description": "Invalid IP address format"
}

ip/get_ptr

Checks and returns the PTR record for the specified IP

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_ptr
token string Authorization token
id integer Server ID
ip string IP address
location string Server location

Example Request

curl -s "https://api.hostkey.com/ip.php" -X POST \
--data "action=get_ptr" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE" \
--data "ip=VALUE"
Example of a successful response
{
"result": "OK",
"action": "get_ptr",
"message": "server10.example.com"
}
Failure response
{
"code": -1,
"message": "invalid IP"
}

ip/get_traffic

Returns incoming and outgoing traffic statistics for an IP over a specified period

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: get_traffic
token string Authorization token
ip string IP address
period_start integer Period start (Unix timestamp)
period_stop integer Period end (Unix timestamp)
summary integer 1 - return summary only, 0 - return all ticks
unbilled integer 1 - unbilled traffic only

Example Request

curl -s "https://api.hostkey.com/ip.php" -X POST \
--data "action=get_traffic" \
--data "token=HOSTKEY_TOKEN" \
--data "ip=192.168.1.10" \
--data "period_start=1704067200" \
--data "period_stop=1704153600" \
--data "summary=0"
Example of a successful response
{
"result": "OK",
"action": "get_traffic",
"traffic": [
  {
    "ip": "192.168.1.10",
    "in": 15.5,
    "out": 8.2,
    "timestamp": 1704067200
  }
]
}
Failure response
{
"code": -1,
"message": "no significant traffic detected for 192.168.1.10 in the period 01-01-2024 - 02-01-2024"
}

ip/list_free_ip

Returns a list of available IP addresses for a specified location or subnet

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: list_free_ip
token string Authorization token
location string Location code
id integer Subnet ID (for clients)
exclude_special integer Exclude special IPs

Example Request

curl -s "https://api.hostkey.com/ip.php" -X POST \
--data "action=list_free_ip" \
--data "token=HOSTKEY_TOKEN" \
--data "location=LOC_CODE" \
--data "id=12345" \
--data "exclude_special=1"
Example of a successful response
{
"result": "OK",
"action": "list_free_ip",
"ip": [
  "192.168.1.50",
  "192.168.1.51",
  "192.168.1.52"
]
}
Failure response
{
"code": -1,
"message": "illegal IP subnet"
}

ip/set_main

Sets the specified IP as the primary IP for the server interface

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: set_main
token string Authorization token
id integer Server ID
ip string IP address to set
main integer Main IP flag (0/1)
description string Action description

Example Request

curl -s "https://api.hostkey.com/ip.php" -X POST \
--data "action=set_main" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE" \
--data "ip=VALUE"
Example of a successful response
{
"result": "OK",
"action": "set_main",
"message": "IP 192.168.1.10 set as main for server 123"
}
Failure response
{
"code": -1,
"message": "invalid IP 192.168.1.10 for server 123"
}

ip/update_ptr

Updates the PTR record (reverse DNS) for the specified IP

HTTP Method: POST

Parameters:

Parameter Required Type Description
action string Method identifier: update_ptr
token string Authorization token
id integer Server ID
ip string IP address
ptr string New PTR value (domain name)
location string Server location

Example Request

curl -s "https://api.hostkey.com/ip.php" -X POST \
--data "action=update_ptr" \
--data "token=HOSTKEY_TOKEN" \
--data "id=VALUE" \
--data "ip=VALUE" \
--data "ptr=VALUE"
Example of a successful response
{
"result": "OK",
"action": "update_ptr",
"message": ""
}
Failure response
{
"code": -1,
"message": "IP 192.168.1.10 is not assigned for server 123"
}

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×