Need to understand a network's characteristics from its CIDR notation? This guide covers everything about getting network information via API, including IP ranges, broadcast addresses, host counts, and implementation examples.
Understanding CIDR Notation
CIDR (Classless Inter-Domain Routing) notation combines an IP address with a prefix length indicating the network portion. For example, 192.168.1.0/24 means:
- IP Address: 192.168.1.0
- Prefix Length: 24 bits are the network portion
- Host Bits: 8 bits (32-24) for host addresses
Network Components
Every network has several key components:
Network Address
The first address in the range, used to identify the network itself.
Broadcast Address
The last address in the range, used to send packets to all hosts in the network.
Usable Host Range
All addresses between network and broadcast addresses that can be assigned to devices.
Using the Network Information API
TinyFn provides a comprehensive endpoint for network analysis:
GET https://api.tinyfn.io/v1/ip/network-info?cidr=192.168.1.0/24
Headers: X-API-Key: your-api-key
{
"cidr": "192.168.1.0/24",
"network_address": "192.168.1.0",
"broadcast_address": "192.168.1.255",
"netmask": "255.255.255.0",
"wildcard": "0.0.0.255",
"first_host": "192.168.1.1",
"last_host": "192.168.1.254",
"total_addresses": 256,
"usable_hosts": 254,
"prefix_length": 24,
"ip_class": "C",
"is_private": true
}
Parameters
| Parameter | Type | Description |
|---|---|---|
cidr |
string | Network in CIDR notation (e.g., 192.168.1.0/24) (required) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/ip/network-info?cidr=10.0.0.0/8',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const info = await response.json();
console.log(`Network: ${info.network_address}`);
console.log(`Broadcast: ${info.broadcast_address}`);
console.log(`Usable hosts: ${info.usable_hosts}`);
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/ip/network-info',
headers={'X-API-Key': 'your-api-key'},
params={'cidr': '10.0.0.0/8'}
)
info = response.json()
print(f"Network: {info['network_address']}")
print(f"Broadcast: {info['broadcast_address']}")
print(f"Usable hosts: {info['usable_hosts']}")
cURL
curl "https://api.tinyfn.io/v1/ip/network-info?cidr=10.0.0.0/8" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Network Planning: Calculate available addresses for new networks
- Infrastructure Documentation: Generate network documentation
- IP Address Management: IPAM systems for tracking allocations
- Security Auditing: Understand network boundaries for security reviews
- Cloud Configuration: Plan VPC and subnet configurations
Best Practices
- Validate CIDR input: Ensure the CIDR notation is valid before sending
- Understand private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
- Plan for growth: Choose network sizes that accommodate future expansion
- Document networks: Use the API to generate network documentation
Try the Network Information API
Get your free API key and start analyzing networks in seconds.
Get Free API Key