Getting started
To use the free APIs, you need to know the base URL for the NetworkCalc APIs. All API calls start with the base URL https://networkcalc.com/api
. If a specific endpoint is given (example: /ip
), it is added onto the end of the base url (example: https://networkcalc.com/api/ip
).
The following free APIs are available for you to use. Click one of the links below to be taken to the API documentation.
Free public APIs
https://networkcalc.com/api
.Below are the different API endpoints that are available for free and links to their documentation pages.
Resource | API Endpoints | Documentation |
---|---|---|
Subnet Calculator | /ip/{subnet} |
Subnet API Documentation |
Binary Converter | /binary/{number} |
Binary Converter API Documentation |
Security Tools | /security/certificate/{hostname} |
Security Tools API Documentation |
DNS Tools | /dns/lookup/{hostname} or /dns/whois/{hostname} or /dns/spf/{hostname} |
DNS Tools API Documentation |
Encoder | /encoder/{value} |
Encoder API Documentation |
Making API calls
You can use many different tools to make API calls. We'll look at how to make an API call using a few different tools below.
The examples below show how to make an API call to NetworkCalc's free public APIs to find out the subnet mask for the IP address network 10.0.1.15/27.
Using cURL
cURL is built into many terminals, including Bash and Command Prompt. To make an API call using cURL, simply open up your terminal application and execute the following command:
curl https://networkcalc.com/api/ip/10.0.1.15/27
The response should look something like the one below. As you can see, the subnet mask is shown as 255.255.255.224
:
{
"status": "OK",
"meta": { "permalink": "https://networkcalc.com/subnet-calculator/10.0.1.15/27", "next_address": "https://networkcalc.com/api/ip/10.0.1.16/27" },
"address": {
"cidr_notation": "10.0.1.15/27",
"subnet_bits": 27,
"subnet_mask": "255.255.255.224",
"wildcard_mask": "0.0.0.31",
"network_address": "10.0.1.0",
"broadcast_address": "10.0.1.31",
"assignable_hosts": 30,
"first_assignable_host": "10.0.1.1",
"last_assignable_host": "10.0.1.30"
}
}
Using Python
You can easily make API calls using the requests
module in Python. You must install the module first using pip or any other Python package manager:
pip install requests
Once you have installed the requests
module in Python, you can make API calls, like in the example below:
import requests
response = requests.get("https://networkcalc.com/api/ip/10.0.1.15/27")
print(response.json())
The response you get back will be a JSON object:
{
"status": "OK",
"meta": { "permalink": "https://networkcalc.com/subnet-calculator/10.0.1.15/27", "next_address": "https://networkcalc.com/api/ip/10.0.1.16/27" },
"address": {
"cidr_notation": "10.0.1.15/27",
"subnet_bits": 27,
"subnet_mask": "255.255.255.224",
"wildcard_mask": "0.0.0.31",
"network_address": "10.0.1.0",
"broadcast_address": "10.0.1.31",
"assignable_hosts": 30,
"first_assignable_host": "10.0.1.1",
"last_assignable_host": "10.0.1.30"
}
}
Using PowerShell
PowerShell is a powerful system administrator tool available by default on the Microsoft Windows operating system. You can make API calls using PowerShell by using the Invoke-WebRequest
cmdlet, as shown in the example below.
Invoke-WebRequest https://networkcalc.com/ip/10.0.1.15/27
The response will contain multiple attributes. The response body you receive from NetworkCalc will be under the Content
attribute:
StatusCode : 200
StatusDescription : OK
Content : {"status":"OK","meta":{"permalink":"https://networkcalc.com/subnet-calculator/10.0.1.15/27","next_a
ddress":"https://networkcalc.com/api/ip/10.0.1.16/27"},"address":{"cidr_notation":"10.0.1.15/27","s
ub...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
Strict-Transport-Security: max-age=31536000; preload;
X-Content-Type-Options: nosniff
Access-Control-Allow-Origin: *
Vary: Accep...
Forms : {}
Headers : {[Transfer-Encoding, chunked], [Connection, keep-alive], [Strict-Transport-Security,
max-age=31536000; preload;], [X-Content-Type-Options, nosniff]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 426
You can simplify this command by calling Invoke-WebRequest
and selecting the Content
attribute directly, as follows:
(Invoke-WebRequest https://networkcalc.com/api/ip/10.0.1.15/27).Content
You may want to work with the data in a format other than JSON. PowerShell has a utility for converting a JSON object to a table, which is easier to work with in PowerShell. To do this, invoke your API call and pipe the results into the ConvertFrom-JSON
cmdlet, as shown below:
(Invoke-WebRequest https://networkcalc.com/api/ip/10.0.1.15/27).Content | ConvertFrom-JSON
You can further select attributes to work with until you get exactly what you are looking for. The command below:
((Invoke-WebRequest https://networkcalc.com/api/ip/10.0.1.15/27).Content | ConvertFrom-JSON).address
produces these results:
cidr_notation : 10.0.1.15/27
subnet_bits : 27
subnet_mask : 255.255.255.224
wildcard_mask : 0.0.0.31
network_address : 10.0.1.0
broadcast_address : 10.0.1.31
assignable_hosts : 30
first_assignable_host : 10.0.1.1
last_assignable_host : 10.0.1.30
Putting it all together
The NetworkCalc APIs provide a free and easy way to find out the details of your subnets so you can build, manage, and monitor your networks. They also provide useful utilities for checking DNS, security certificates, and performing binary conversions or Base64 encodings.
For details on each of the NetworkCalc APIs and their capabilities, it is recommended to review the API documentation.