Skip to content

Subnet Lookup

Look up threat intelligence for all IPs within a subnet range using CIDR notation.

Endpoint

http
GET https://ipswamp.com/api/v1/checkSubnet

Request

Headers

HeaderRequiredDescription
AuthorizationYes*Bearer <api-key>
X-API-KeyYes*Alternative to Authorization header

INFO

One of Authorization or X-API-Key is required.

Query Parameters

ParameterTypeRequiredDescription
cidrstringYesCIDR notation of the subnet to scan (e.g., 1.2.3.0/24)

WARNING

The maximum supported subnet size is /24 (256 IP addresses). Larger subnets will return a 400 error.

Response

Success (200)

Returns threat intelligence data for each IP in the subnet along with a summary.

json
{
  "cidr": "1.2.3.0/24",
  "network": "1.2.3.0",
  "broadcast": "1.2.3.255",
  "total_ips": 254,
  "results": [
    {
      "ip": "1.2.3.1",
      "threat_score": 85,
      "threat_level": "CRITICAL",
      "last_attack": "2026-04-15T10:30:00.000Z",
      "ip_rep": "known attacker",
      "total_hits": 142
    },
    {
      "ip": "1.2.3.2",
      "threat_score": 0,
      "threat_level": "LOW",
      "last_attack": null,
      "ip_rep": "clean",
      "total_hits": 0
    }
  ],
  "summary": {
    "total": 254,
    "malicious": 3,
    "clean": 251,
    "average_score": 1.2,
    "found_count": 3
  }
}

Response Fields

FieldTypeDescription
cidrstringThe requested CIDR range
networkstringThe network address of the subnet
broadcaststringThe broadcast address of the subnet
total_ipsnumberTotal number of usable IPs (excluding network/broadcast)
resultsarrayArray of IP results found in the threat database
summaryobjectAggregated statistics for the subnet

INFO

The results array only includes IPs found in the threat database. IPs with no threat data are not included in the results.

Result Object

FieldTypeDescription
ipstringThe IP address
threat_scorenumberThreat score from 0 to 100
threat_levelstringSeverity bucket: LOW, MEDIUM, HIGH, CRITICAL
last_attackstringISO timestamp of last detected attack
ip_repstringReputation classification
total_hitsnumberTotal number of malicious hits recorded

Summary Object

FieldTypeDescription
totalnumberTotal usable IPs in the subnet
maliciousnumberNumber of IPs with threat data
cleannumberNumber of IPs without threat data
average_scorenumberAverage threat score across found IPs
found_countnumberNumber of IPs found in the threat database

Error Responses

StatusResponseDescription
400{ "error": true, "statusCode": 400, "message": "CIDR is required" }Missing CIDR parameter
400{ "error": true, "statusCode": 400, "message": "Invalid CIDR format" }Malformed CIDR notation
400{ "error": true, "statusCode": 400, "message": "Maximum /24 subnet size" }Subnet too large
401{ "error": true, "statusCode": 401, "message": "API key required..." }No API key provided
403{ "error": true, "statusCode": 403, "message": "Invalid API key" }Invalid or expired API key
429{ "error": true, "statusCode": 429, "message": "Rate limit exceeded" }Too many requests
500{ "error": true, "statusCode": 500, "message": "Internal server error" }Server error

Quota

Each IP found in the threat database counts as 1 toward your usage quota. IPs without threat data do not count.

Examples

Basic Request

bash
curl -X GET "https://ipswamp.com/api/v1/checkSubnet?cidr=1.2.3.0/24" \
  -H "Authorization: Bearer your-api-key-here"

Using X-API-Key Header

bash
curl -X GET "https://ipswamp.com/api/v1/checkSubnet?cidr=1.2.3.0/24" \
  -H "X-API-Key: your-api-key-here"

JavaScript/TypeScript

typescript
const cidr = "1.2.3.0/24";
const response = await fetch(
  `https://ipswamp.com/api/v1/checkSubnet?cidr=${encodeURIComponent(cidr)}`,
  {
    headers: {
      Authorization: "Bearer your-api-key-here",
    },
  },
);

const data = await response.json();
console.log(
  `Subnet ${data.cidr}: ${data.summary.malicious} malicious IPs out of ${data.summary.total}`
);

Python

python
import requests

url = "https://ipswamp.com/api/v1/checkSubnet"
params = {"cidr": "1.2.3.0/24"}
headers = {
    "Authorization": "Bearer your-api-key-here"
}

response = requests.get(url, params=params, headers=headers)
data = response.json()

print(f"Subnet {data['cidr']}: "
      f"{data['summary']['malicious']} malicious IPs out of {data['summary']['total']}")

See Also

IPSwamp API Documentation