# Subnet API
> A fast, fully-local IP and subnet calculator: validate IPv4 and IPv6 addresses with type classification (private, public, loopback, link-local, multicast, CGNAT or reserved), compute CIDR subnet details (network, netmask, wildcard, broadcast, first and last host, total addresses and usable hosts, with IPv6 network and range size), check whether an address falls inside a CIDR block, and convert addresses (IPv4 to integer, hex and binary; IPv6 expand and compress). Every endpoint accepts input via the query string or the request body. Pure server-side compute, no third-party upstream, so responses are instant and always available. Ideal for devops, network automation, IPAM, firewall and ACL tooling and cloud infrastructure.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/subnet-api/..."
```

## Pricing
- **Free** (Free) — 14,000 calls/Mo, 3 req/s
- **Basic** ($4/Mo) — 240,000 calls/Mo, 12 req/s
- **Pro** ($15/Mo) — 1,300,000 calls/Mo, 40 req/s
- **Mega** ($40/Mo) — 6,800,000 calls/Mo, 120 req/s

## Endpoints

### Subnet

#### `GET /v1/contains` — Is an IP inside a CIDR

**Parameters:**
- `cidr` (query, required, string) — CIDR block Example: `10.0.0.0/8`
- `ip` (query, required, string) — IP address Example: `10.1.2.3`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/subnet-api/v1/contains?cidr=10.0.0.0%2F8&ip=10.1.2.3"
```

**Response:**
```json
{
    "data": {
        "ip": "10.1.2.3",
        "cidr": "10.0.0.0/8",
        "contains": true
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:56.481Z",
        "request_id": "1e36be8f-58ce-4878-9526-99fcbaa4c1db"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/convert` — Convert an IP address

**Parameters:**
- `ip` (query, required, string) — IPv4 or IPv6 address Example: `192.168.1.1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/subnet-api/v1/convert?ip=192.168.1.1"
```

**Response:**
```json
{
    "data": {
        "ip": "192.168.1.1",
        "hex": "0xc0a80101",
        "binary": "11000000.10101000.00000001.00000001",
        "integer": 3232235777,
        "version": 4
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:56.567Z",
        "request_id": "0d327fbd-fd2f-4c96-b39b-fd406b9f2c3e"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/subnet` — CIDR subnet calculator

**Parameters:**
- `cidr` (query, required, string) — address/prefix Example: `192.168.1.0/24`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/subnet-api/v1/subnet?cidr=192.168.1.0%2F24"
```

**Response:**
```json
{
    "data": {
        "cidr": "192.168.1.0/24",
        "prefix": 24,
        "netmask": "255.255.255.0",
        "network": "192.168.1.0",
        "version": 4,
        "wildcard": "0.0.0.255",
        "broadcast": "192.168.1.255",
        "last_host": "192.168.1.254",
        "first_host": "192.168.1.1",
        "usable_hosts": 254,
        "total_addresses": 256
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:56.638Z",
        "request_id": "94f08fee-7e90-4133-a164-e5eeb7900758"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/validate` — Validate an IP address

**Parameters:**
- `ip` (query, required, string) — IPv4 or IPv6 address Example: `192.168.1.10`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/subnet-api/v1/validate?ip=192.168.1.10"
```

**Response:**
```json
{
    "data": {
        "ip": "192.168.1.10",
        "type": "private",
        "valid": true,
        "integer": 3232235786,
        "version": 4,
        "is_private": true
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:56.724Z",
        "request_id": "c42b0dcc-fdcc-40d1-a61c-8f6738bb4a2f"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/subnet-api
OpenAPI spec: https://www.oanor.com/api/subnet-api/openapi.json
