IPv4 Subnet Calculator API Documentation¶
Overview¶
The IPv4 Subnet Calculator API provides detailed subnet information for a given IPv4 address and subnet specification.
It accepts either a CIDR prefix or a subnet mask and returns a comprehensive report including network details, broadcast address, usable hosts, and IP classification.
This API is available at:
https://api.apidatatools.com/ipv4-subnet-calculator-api
Endpoint (POST)¶
POST https://api.apidatatools.com/ipv4-subnet-calculator-api
Performs subnet calculation based on the provided IPv4 address and subnet mask or CIDR.
Headers¶
| Header | Description | Example |
|---|---|---|
Content-Type | Must be application/json | application/json |
x-source-type | Defines input mode (body, url, or file) | body |
x-api-key | Your API key for authentication. | <api_key> |
Accepted File Extensions¶
This tool supports body mode only.
No file or URL input is accepted.
Input Example (Body Mode)¶
{
"ip": "192.168.1.10",
"cidr": 24
}
or
{
"ip": "192.168.1.10",
"mask": "255.255.255.0"
}
Example Request¶
Synchronous (Body Input)¶
curl -X POST "https://api.apidatatools.com/ipv4-subnet-calculator-api" \
-H "Content-Type: application/json" \
-H "x-source-type: body" \
-d '{
"ip": "192.168.1.10",
"cidr": 24
}'
Example Response¶
Successful (Body Mode)¶
{
"status": "success",
"request_id": "b12f9e3a-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"preview": "{\n \"ip_address\": {\n \"quads\": \"192.168.1.10\",\n \"binary\": \"11000000101010000000000100001010\",\n \"hex\": \"C0A8010A\",\n \"integer\": 3232235786\n },\n \"subnet_mask\": {\n \"quads\": \"255.255.255.0\",\n \"binary\": \"11111111111111111111111100000000\",\n \"hex\": \"FFFFFF00\",\n \"integer\": 4294967040\n },\n \"cidr\": 24,\n \"network\": {\n \"quads\": \"192.168.1.0\",\n \"binary\": \"11000000101010000000000100000000\",\n \"hex\": \"C0A80100\",\n \"integer\": 3232235776\n },\n \"broadcast\": {\n \"quads\": \"192.168.1.255\",\n \"binary\": \"11000000101010000000000111111111\",\n \"hex\": \"C0A801FF\",\n \"integer\": 3232236031\n },\n \"wildcard_mask\": \"0.0.0.255\",\n \"total_ips\": 256,\n \"usable_hosts\": 254,\n \"first_host\": \"192.168.1.1\",\n \"last_host\": \"192.168.1.254\",\n \"range\": \"192.168.1.0 - 192.168.1.255\",\n \"hosts\": [\"192.168.1.1\", \"192.168.1.2\", ...],\n \"ip_type\": {\n \"is_private\": true,\n \"is_loopback\": false,\n \"is_multicast\": false,\n \"is_link_local\": false,\n \"is_reserved\": false,\n \"is_global\": false\n }\n}"
}
Error Handling¶
Below are possible error codes and example responses.
| Error Code | Description | Example Response |
|---|---|---|
INVALID_JSON | Request body is not valid JSON | {"status":"error","error":"INVALID_JSON","request_id":"...","details":{"message":"Request body must be valid JSON."}} |
MISSING_IP | Missing required ip field | {"status":"error","error":"MISSING_IP","request_id":"...","details":{"message":"'ip' field is required."}} |
MISSING_MASK_OR_CIDR | Neither cidr nor mask provided | {"status":"error","error":"MISSING_MASK_OR_CIDR","request_id":"...","details":{"message":"Provide either 'cidr' or 'mask'."}} |
INVALID_CIDR | CIDR is not an integer or out of range | {"status":"error","error":"INVALID_CIDR","request_id":"...","details":{"message":"CIDR must be integer between 0 and 32."}} |
INVALID_MASK | Subnet mask is invalid | {"status":"error","error":"INVALID_MASK","request_id":"...","details":{"message":"Invalid subnet mask."}} |
INVALID_SUBNET | Invalid IP or subnet combination | {"status":"error","error":"INVALID_SUBNET","request_id":"...","details":{"message":"Invalid IP or subnet."}} |
PROCESSING_ERROR | Internal processing failure | {"status":"error","error":"PROCESSING_ERROR","request_id":"...","details":{"message":"Failed to generate subnet report."}} |
PAYLOAD_TOO_LARGE | Request body exceeds plan limit | {"status":"error","error":"PAYLOAD_TOO_LARGE","request_id":"...","details":{"message":"Request body exceeds limit for your plan."}} |
UNKNOWN_FUNCTION | Endpoint not recognized | {"status":"error","error":"UNKNOWN_FUNCTION","request_id":"...","details":{"message":"Unsupported API endpoint."}} |
INTERNAL_ERROR | Unexpected internal error | {"status":"error","error":"INTERNAL_ERROR","request_id":"...","details":{"message":"Failed to process your request"}} |
Async Job Status¶
Not applicable for this tool.
This API operates synchronously only.
Notes for Developers¶
- This API supports only body-based synchronous requests.
- Each response includes a unique
request_idfor tracking and logging. - Ensure
Content-Type: application/jsonis set in all requests. - The tool does not support URL or file-based asynchronous operations.
- CIDR must be an integer between 0 and 32.
- Either
cidrormaskmust be provided, not both. - The response includes detailed IP representations (binary, hex, integer).
- For large subnets (>1024 addresses), host listing is replaced with
"Too large to list". - Use the
request_idfor debugging or support queries.