# Network CIDR lookup

> Inspect canonical routing prefix intelligence by split CIDR (/v1/networks/:prefix/:length) or URL-encoded CIDR (/v1/networks/:cidr).

```http
GET https://api.ipscope.io/v1/networks/{prefix}/{length}
```

Authentication: API key (`X-API-Key` header or `Authorization: Bearer`). Plan: scope: lookup

```http
GET https://api.ipscope.io/v1/networks/{cidr}
```

Authentication: API key (`X-API-Key` header or `Authorization: Bearer`). Plan: scope: lookup

Queries the active snapshot for a canonical network prefix record. `LookupController` supports both **split path parameters** (`/v1/networks/198.51.100.0/24`) and **URL-encoded CIDR notation** (`/v1/networks/198.51.100.0%2F24`) so reverse proxies that disallow encoded slashes (`%2F`) work without special configuration.

**Path parameters**

- `prefix` (string, required): IPv4 or IPv6 network address (`"198.51.100.0"` or `"2606:4700:4700::"`).
- `length` (integer, required): Prefix mask length: `0..32` for IPv4 or `0..128` for IPv6. Host bits are automatically masked to the canonical network address.
- `cidr` (string): Alternative single-parameter URL-encoded CIDR (`"198.51.100.0%2F24"`). Used automatically by `client.lookupNetwork("198.51.100.0/24")` in all official SDKs.

## Code examples

```bash curl
curl -sS "https://api.ipscope.io/v1/networks/198.51.100.0/24" \
  -H "Authorization: Bearer $IPSCOPE_KEY"
```

```python Python
import asyncio, os
from ipscope import AsyncIpScopeClient

async def main() -> None:
    async with AsyncIpScopeClient(api_key=os.environ["IPSCOPE_KEY"]) as client:
        prefix = await client.lookup_network("198.51.100.0/24")
        print(prefix["queried_cidr"], prefix["record"]["asn"], prefix["record"]["organization"])

asyncio.run(main())
```

```ts Node.js
import { IpScopeClient } from '@ipscope/sdk-node';

const client = new IpScopeClient({ apiKey: process.env.IPSCOPE_KEY });
const prefix = await client.lookupNetwork('198.51.100.0/24');
console.log(prefix.queried_cidr, prefix.record?.asn, prefix.record?.organization);
```

```go Go
client := ipscope.NewClient(ipscope.Config{APIKey: os.Getenv("IPSCOPE_KEY")})
defer client.Close()

prefix, err := client.LookupNetwork(ctx, "198.51.100.0/24")
if err != nil {
	return err
}
fmt.Println(prefix.QueriedCIDR, prefix.Record.ASN, prefix.Record.Organization)
```

```rust Rust
use ipscope::{AsyncIpScopeClient, ClientConfig};

let client = AsyncIpScopeClient::new(ClientConfig::new(std::env::var("IPSCOPE_KEY")?))?;
let prefix = client.lookup_network("198.51.100.0/24").await?;
println!("{} ASN={:?}", prefix.queried_cidr, prefix.record.asn);
```

## Responses

### 200 `NetworkPrefixLookupResponse`: Canonical network prefix record from the active routing snapshot.

- `queried_cidr` (string, required): Normalized canonical CIDR block.
- `family` (integer, required): IP address family (`4` or `6`).
- `dataset_version` (string, required): Active dataset snapshot version.
- `record` (NetworkPrefixRecord, required): Matched prefix record in the routing snapshot.
  - `prefix` (string, required): Matched CIDR prefix in the routing table.
  - `family` (integer, required): Address family (`4` or `6`).
  - `asn` (integer, optional, nullable): Origin Autonomous System Number.
  - `organization` (string, optional, nullable): Registered autonomous system organization name.
  - `countryCode` (string, optional, nullable): ISO 3166-1 alpha-2 country code.
  - `city` (string, optional, nullable): Resolved city name.
  - `locationType` (string, required): Location resolution classification.
  - `isVpn` (boolean, required): Whether the prefix is classified as a VPN exit range.
  - `isHosting` (boolean, required): Whether the prefix belongs to a hosting/cloud ASN.
  - `isTorExit` (boolean, required): Whether the prefix contains active Tor exit nodes.
  - `isProxy` (boolean, required): Whether the prefix contains active proxy relays.
  - `anonymizerType` (string, required): Primary anonymizer classification (`"vpn"`, `"none"`, etc.).

```json 200 NetworkPrefixLookupResponse
{
  "queried_cidr": "198.51.100.0/24",
  "family": 4,
  "dataset_version": "2026-10-27T00:00:00Z.crawl-1793088000000",
  "record": {
    "prefix": "198.51.100.0/24",
    "family": 4,
    "asn": 64501,
    "organization": "Example Cloud LLC",
    "countryCode": "US",
    "city": "Ashburn",
    "locationType": "physical",
    "isVpn": true,
    "isHosting": true,
    "isTorExit": false,
    "isProxy": false,
    "anonymizerType": "vpn"
  }
}
```

### 400 `ApiError`: Invalid IPv4/IPv6 network address or prefix length outside 0..32 (IPv4) / 0..128 (IPv6).

- `statusCode` (integer, required): HTTP status code returned by the API gateway.
- `message` (string, required): Human-readable diagnostic message describing the error condition.
- `error` (string, required): Canonical HTTP error classification.

```json 400 ApiError
{
  "statusCode": 400,
  "message": "Invalid CIDR prefix length: 33 for IPv4",
  "error": "Bad Request"
}
```

### 404 `ApiError`: No network prefix record found for the queried CIDR in the active snapshot.

- `statusCode` (integer, required): HTTP status code returned by the API gateway.
- `message` (string, required): Human-readable diagnostic message describing the error condition.
- `error` (string, required): Canonical HTTP error classification.

```json 404 ApiError
{
  "statusCode": 404,
  "message": "No network record found for prefix 198.51.100.0/24",
  "error": "Not Found"
}
```
