About the Subnet Calculator API

API Version: 1.9

The Subnet Calculator allows you to determine network details for an IPv4 subnet, given an address in dotted-decimal notation (w.x.y.z) or CIDR notation (w.x.y.z/s).

This is the API for the Subnet Calculator.

See also: Subnets API

Endpoints

https://networkcalc.com/api/ip/{subnet}

Calculates the details for a subnet, specified as an IPv4 address or CIDR block.

Example request and response
curl https://networkcalc.com/api/ip/10.5.1.0/27?binary=true

{
  "status": "OK",
  "meta": {
    "permalink": "https://networkcalc.com/ip/10.5.1.0/27?binary=1",
    "next_address": "https://networkcalc.com/api/ip/10.5.1.1/27?binary=1"
  },
  "address": {
    "cidr_notation": "10.5.1.0/27",
    "subnet_bits": 27,
    "subnet_mask": "255.255.255.224",
    "wildcard_mask": "0.0.0.31",
    "network_address": "10.5.1.0",
    "broadcast_address": "10.5.1.31",
    "assignable_hosts": 30,
    "first_assignable_host": "10.5.1.1",
    "last_assignable_host": "10.5.1.30",
    "binary": {
      "octet_1": "00001010",
      "octet_2": "00000101",
      "octet_3": "00000001",
      "octet_4": "00000000",
      "address": "00001010 00000101 00000001 00000000",
      "subnet_mask": "11111111 11111111 11111111 11100000",
      "wildcard_mask": "00000000 00000000 00000000 00011111",
      "network_address": "00001010 00000101 00000001 00000000",
      "broadcast_address": "00001010 00000101 00000001 00011111",
      "first_assignable_host": "00001010 00000101 00000001 00000001",
      "last_assignable_host": "00001010 00000101 00000001 00011110"
    }
  }
}

Parameters

{subnet}

(Required) The requested IPv4 address or CIDR block to calculate. To calculate multiple subnets, use the format [subnet_1,subnet_2,...].

Example: https://networkcalc.com/api/ip/192.168.1.1/24

binary

(Optional) include('a binary representation of the subnet in the response.

Values: 0,false,1,true

Example: https://networkcalc.com/api/ip/192.168.1.1/24?binary=true

fields

(Optional) A comma-separated list of fields to include. By default, all available fields are included.

Response Codes

200
OK - Success.
400
NO_ADDRESS_SPECIFIED - The {subnet} parameter was not specified.
400
INVALID_ADDRESS - the address or addresses specified as {subnet} are invalid.

Response Formats

{
  "status": "[string] The status of the request.",
  "meta": {
    "permalink": "[string] A hyperlink to the browser results (API permalink) for the subnet.",
    "next_address": "[string] The IP address sequentially following the one requested. Useful for iterating."
  },
  "address": {
    "cidr_notation": "[string] The requested address in CIDR notation, per RFC 4632.",
    "subnet_bits": "[number] The number of bits representing the subnet mask.",
    "subnet_mask": "[string] The subnet mask in dotted-decimal notation.",
    "wildcard_mask": "[string] The wildcard (inverted subnet) mask in dotted-decimal notation.",
    "network_address": "[string] The network ID for the subnet (first address in the subnet; unassignable).",
    "broadcast_address": "[string] The broadcast address for the subnet (last address in the subnet; unassignable).",
    "assignable_hosts": "[number] The number of assignable hosts in the subnet.",
    "first_assignable_host": "[string] The IP address representing the first assignable host or null.",
    "last_assignable_host": "[string] The IP address representing the last assignable host or null.",
    "binary": "[Object] (Optional) See SubnetAddressBinary"
  }
}
{
  "octet_1": "[string] Binary representation of the first octet of the requested address.",
  "octet_2": "[string] Binary representation of the second octet of the requested address.",
  "octet_3": "[string] Binary representation of the third octet of the requested address.",
  "octet_4": "[string] Binary representation of the fourth octet of the requested address.",
  "address": "[string] Binary representation of the requested address.",
  "subnet_mask": "[string]",
  "wildcard_mask": "[string]",
  "network_address": "[string]",
  "broadcast_address": "[string]",
  "first_assignable_host": "[string]",
  "last_assignable_host": "[string]"
}