
Subnet Calculator API
Development
Calculate an IPv4 subnet from CIDR notation or a mask: network and broadcast addresses, usable host range, host count, wildcard mask, binary view, and subnet splitting.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
120 requests per minute
Endpoints
2 endpoints available
Overview
IPv4 subnet maths: network and broadcast addresses, usable host range, masks, counts, a binary breakdown, and an optional split into smaller subnets. IPv6 is not supported.
Address formats
- CIDR:
10.0.0.5/16 - Address and mask:
10.0.0.5 255.255.0.0or10.0.0.5/255.255.0.0 - A bare address such as
10.0.0.5uses theprefixfield (default 24)
Notes
- A /31 is a point-to-point link (RFC 3021) and a /32 is a single host, so neither reserves network and
broadcast addresses.
usableHostsis 2 and 1 for those. splitPrefixdivides the network into equal subnets of that size. It must be larger than the network's own prefix. At most 1024 subnets are listed;split.totalis the true count andsplit.truncatedtells you when the list was cut.- This endpoint accepts GET (query string) and POST (JSON).
Endpoints
GET
https://opentools.ca/api/v1/tools/subnet-calculatorCalculate a subnet from query parameters
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| address | string | Required | IPv4 address with a prefix or mask, e.g. "192.168.1.10/24". URL-encode it. |
| prefix | number | Optional | Prefix length, 0 to 32. Used only when address has no prefix or mask.Default: 24 |
| splitPrefix | number | Optional | Split the network into subnets of this prefix length (larger than the network prefix, up to 32). |
Response Example
{
"success": true,
"network": "192.168.1.0",
"cidr": "192.168.1.0/24",
"broadcast": "192.168.1.255",
"firstHost": "192.168.1.1",
"lastHost": "192.168.1.254",
"usableHosts": 254,
"totalAddresses": 256,
"prefix": 24,
"mask": "255.255.255.0",
"wildcard": "0.0.0.255",
"ip": "192.168.1.10",
"ipHex": "0xC0A8010A",
"ipInteger": 3232235786,
"ipClass": "C",
"addressType": "Private (RFC 1918)",
"binary": {
"address": "11000000.10101000.00000001.00001010",
"mask": "11111111.11111111.11111111.00000000",
"network": "11000000.10101000.00000001.00000000",
"broadcast": "11000000.10101000.00000001.11111111"
}
}Error Codes
400
Bad Request - Invalid address, mask or prefix, or splitPrefix not larger than the network prefix401
Unauthorized - Invalid or missing API key403
Forbidden - API key inactive, expired, or request from a disallowed IP429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorPOST
https://opentools.ca/api/v1/tools/subnet-calculatorCalculate a subnet from a JSON body (same fields and response as GET)
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| address | string | Required | IPv4 address with a prefix or mask, e.g. "192.168.1.10/24" or "10.0.0.5 255.255.0.0". |
| prefix | number | Optional | Prefix length, 0 to 32. Used only when address has no prefix or mask.Default: 24 |
| splitPrefix | number | Optional | Split the network into subnets of this prefix length. Adds a split object with total, returned, truncated and subnets (cidr, network, firstHost, lastHost, broadcast, usableHosts). |
Response Example
{
"success": true,
"network": "192.168.1.0",
"cidr": "192.168.1.0/24",
"broadcast": "192.168.1.255",
"usableHosts": 254,
"split": {
"prefix": 26,
"total": 4,
"returned": 4,
"truncated": false,
"subnets": [
{
"cidr": "192.168.1.0/26",
"network": "192.168.1.0",
"firstHost": "192.168.1.1",
"lastHost": "192.168.1.62",
"broadcast": "192.168.1.63",
"usableHosts": 62
}
]
}
}Error Codes
400
Bad Request - Invalid address, mask or prefix, or splitPrefix not larger than the network prefix401
Unauthorized - Invalid or missing API key403
Forbidden - API key inactive, expired, or request from a disallowed IP429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode Examples
# GET
curl -G https://opentools.ca/api/v1/tools/subnet-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "address=192.168.1.10/24"
# POST, split into /26 subnets
curl -X POST https://opentools.ca/api/v1/tools/subnet-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"address": "192.168.1.10/24", "splitPrefix": 26}'Rather use it in your browser? Open the Subnet Calculator