Packetrove CIDR API

IP address and CIDR calculations.

GitHub OpenAPI

Operations 3

POST /v1/cidr-cover Find the smallest single CIDR covering all inputs #
POST /v1/cidr-subtract Subtract excluded networks from included address space exactly #
POST /v1/range-to-cidrs Convert an inclusive IP range to its minimal exact CIDR list #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/packetrove-com:packetrove-com-cidr-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

packetrove-com-cidr-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Packetrove CIDR API
  version: 0.8.0
  license:
    name: MIT
    url: https://opensource.org/license/mit/
  description: Network tools for humans and agents, including local calculations and request-based diagnostics. Address counts are decimal strings for exact IPv6 representation.
servers:
- url: /
  description: The host serving this specification
security: []
tags:
- name: CIDR
  description: IP address and CIDR calculations.
paths:
  /v1/cidr-cover:
    post:
      operationId: cidr-cover
      tags:
      - CIDR
      summary: Find the smallest single CIDR covering all inputs
      description: Accepts IPv4 or IPv6 addresses and CIDRs from one address family. The output maximizes the prefix length while covering every input address, and may include additional addresses. Overlapping inputs are counted once. CIDRs with host bits are normalized. The request body must not exceed 65536 bytes. This is a stateless calculation and does not modify firewall rules.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            examples:
              example1:
                summary: Adjacent IPv4 ranges without expansion
                value:
                  inputs:
                  - 203.0.113.0/25
                  - 203.0.113.128/25
              example2:
                summary: Multiple IPv4 addresses with expansion
                value:
                  inputs:
                  - 203.0.113.1
                  - 203.0.113.2
                  - 203.0.113.6
              example3:
                summary: IPv6 counts beyond the JavaScript safe integer range
                value:
                  inputs:
                  - 2001:db8::/64
                  - 2001:db8:0:1::/64
            schema:
              $ref: '#/components/schemas/CidrCoverRequest'
      responses:
        '200':
          description: The calculated result and exact address counts.
          content:
            application/json:
              examples:
                example1:
                  summary: Adjacent IPv4 ranges without expansion
                  value:
                    family: ipv4
                    normalizedInputs:
                    - 203.0.113.0/25
                    - 203.0.113.128/25
                    cidr: 203.0.113.0/24
                    range:
                      first: 203.0.113.0
                      last: 203.0.113.255
                    inputAddressCount: '256'
                    coveredAddressCount: '256'
                    additionalAddressCount: '0'
                example2:
                  summary: Multiple IPv4 addresses with expansion
                  value:
                    family: ipv4
                    normalizedInputs:
                    - 203.0.113.1/32
                    - 203.0.113.2/32
                    - 203.0.113.6/32
                    cidr: 203.0.113.0/29
                    range:
                      first: 203.0.113.0
                      last: 203.0.113.7
                    inputAddressCount: '3'
                    coveredAddressCount: '8'
                    additionalAddressCount: '5'
                example3:
                  summary: IPv6 counts beyond the JavaScript safe integer range
                  value:
                    family: ipv6
                    normalizedInputs:
                    - 2001:db8::/64
                    - 2001:db8:0:1::/64
                    cidr: 2001:db8::/63
                    range:
                      first: '2001:db8::'
                      last: 2001:db8:0:1:ffff:ffff:ffff:ffff
                    inputAddressCount: '36893488147419103232'
                    coveredAddressCount: '36893488147419103232'
                    additionalAddressCount: '0'
              schema:
                $ref: '#/components/schemas/CidrCoverResult'
        '400':
          description: Invalid JSON, invalid input, or mixed address families. Input issues include a zero-based index.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '405':
          description: Method is not supported for this endpoint.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: Request body exceeds 64 KiB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '415':
          description: Expected an application/json request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Unexpected internal failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/cidr-subtract:
    post:
      operationId: cidr-subtract
      tags:
      - CIDR
      summary: Subtract excluded networks from included address space exactly
      description: Return the minimal sorted canonical CIDR list for union(include) minus union(exclude), without adding addresses. Use one address family and at most 1000 entries across both lists, with at most 64 characters per entry. Include must be nonempty; exclude may be empty. Overlaps count once and host bits are normalized. Results include exact decimal-string counts; complete removal succeeds with an empty list. Results exceeding 10000 CIDRs fail without returning a partial list. The request body must not exceed 65536 bytes. Calls send inputs to the server; no firewall or WireGuard configuration is changed and remaining ranges do not prove live availability.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            examples:
              example1:
                summary: IPv4
                value:
                  include:
                  - 203.0.113.0/24
                  exclude:
                  - 203.0.113.64/26
              example2:
                summary: IPv6
                value:
                  include:
                  - 2001:db8::/124
                  exclude:
                  - 2001:db8::4/126
            schema:
              $ref: '#/components/schemas/CidrSubtractRequest'
      responses:
        '200':
          description: The calculated result and exact address counts.
          content:
            application/json:
              examples:
                example1:
                  summary: IPv4
                  value:
                    family: ipv4
                    normalizedInclude:
                    - 203.0.113.0/24
                    normalizedExclude:
                    - 203.0.113.64/26
                    cidrs:
                    - 203.0.113.0/26
                    - 203.0.113.128/25
                    includedAddressCount: '256'
                    removedAddressCount: '64'
                    remainingAddressCount: '192'
                example2:
                  summary: IPv6
                  value:
                    family: ipv6
                    normalizedInclude:
                    - 2001:db8::/124
                    normalizedExclude:
                    - 2001:db8::4/126
                    cidrs:
                    - 2001:db8::/126
                    - 2001:db8::8/125
                    includedAddressCount: '16'
                    removedAddressCount: '4'
                    remainingAddressCount: '12'
              schema:
                $ref: '#/components/schemas/CidrSubtractResult'
        '400':
          description: Invalid JSON, invalid input, mixed address families, or output limit exceeded. Entry issues include a zero-based index and identify the include/exclude list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '405':
          description: Method is not supported for this endpoint.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: Request body exceeds 64 KiB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '415':
          description: Expected an application/json request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Unexpected internal failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/range-to-cidrs:
    post:
      operationId: range-to-cidrs
      tags:
      - CIDR
      summary: Convert an inclusive IP range to its minimal exact CIDR list
      description: Accept exactly one start and one end IP address of the same family, without CIDR prefixes, at most 64 characters each. Both endpoints are inclusive; end must be at or after start and endpoints are never swapped. Return canonical endpoints and the minimal sorted non-overlapping CIDR list covering exactly that range, with cidrCount and an exact decimal-string addressCount. Every address counts, including IPv4 network and broadcast addresses. Calculations do not enumerate addresses. The request body must not exceed 65536 bytes. Calls submit inputs to the server; no live allocation or firewall configuration is inspected or changed.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            examples:
              example1:
                summary: IPv4
                value:
                  start: 203.0.113.11
                  end: 203.0.113.23
              example2:
                summary: IPv6
                value:
                  start: 2001:db8::b
                  end: 2001:db8::17
            schema:
              $ref: '#/components/schemas/RangeToCidrsRequest'
      responses:
        '200':
          description: The calculated result and exact address counts.
          content:
            application/json:
              examples:
                example1:
                  summary: IPv4
                  value:
                    family: ipv4
                    range:
                      first: 203.0.113.11
                      last: 203.0.113.23
                    cidrs:
                    - 203.0.113.11/32
                    - 203.0.113.12/30
                    - 203.0.113.16/29
                    cidrCount: 3
                    addressCount: '13'
                example2:
                  summary: IPv6
                  value:
                    family: ipv6
                    range:
                      first: 2001:db8::b
                      last: 2001:db8::17
                    cidrs:
                    - 2001:db8::b/128
                    - 2001:db8::c/126
                    - 2001:db8::10/125
                    cidrCount: 3
                    addressCount: '13'
              schema:
                $ref: '#/components/schemas/RangeToCidrsResult'
        '400':
          description: Invalid JSON, invalid endpoints, mixed address families, or reversed range. Issues identify the start or end field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '405':
          description: Method is not supported for this endpoint.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: Request body exceeds 64 KiB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '415':
          description: Expected an application/json request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Unexpected internal failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CidrSubtractRequest:
      type: object
      properties:
        include:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          minItems: 1
          maxItems: 1000
          description: The nonempty included address space. Use at most 1,000 entries across include and exclude, from one address family.
        exclude:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          maxItems: 1000
          description: Ranges to remove from the included address space. An empty array simplifies the exact include union.
      required:
      - include
      - exclude
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
              - INVALID_INPUT
              - MIXED_ADDRESS_FAMILIES
              - INVALID_JSON
              - PAYLOAD_TOO_LARGE
              - UNSUPPORTED_MEDIA_TYPE
              - NOT_FOUND
              - METHOD_NOT_ALLOWED
              - INTERNAL_ERROR
              - CLIENT_IP_UNAVAILABLE
              - NETWORK_ERROR
              - INVALID_RESPONSE
            message:
              type: string
            issues:
              type: array
              items:
                type: object
                properties:
                  index:
                    type: integer
                    minimum: 0
                    description: Zero-based index in inputs, or in the identified include/exclude list.
                  list:
                    type: string
                    minLength: 1
                    description: The input list containing the invalid entry. Existing subtraction errors use include or exclude.
                  field:
                    type: string
                    minLength: 1
                    description: The input field containing the invalid value. Existing range errors use start or end.
                  path:
                    type: array
                    items:
                      anyOf:
                      - type: string
                        minLength: 1
                      - type: integer
                        minimum: 0
                    description: Input field names and zero-based array indices, from the request root. An empty path identifies the whole request. Takes precedence over legacy field, list, and index locations.
                  message:
                    type: string
                  location:
                    type: object
                    properties:
                      line:
                        type: integer
                        minimum: 1
                      offset:
                        type: integer
                        minimum: 0
                      end:
                        type: integer
                        minimum: 0
                    required:
                    - line
                    - offset
                    - end
                    additionalProperties: false
                    description: 'Original text location: one-based line and zero-based UTF-16 start/end offsets. Certificate PEM errors use this to identify rejected material without echoing it.'
                required:
                - message
                additionalProperties: false
          required:
          - code
          - message
          additionalProperties: false
      required:
      - error
      additionalProperties: false
    RangeToCidrsResult:
      type: object
      properties:
        family:
          type: string
          enum:
          - ipv4
          - ipv6
        range:
          type: object
          properties:
            first:
              type: string
            last:
              type: string
          required:
          - first
          - last
          additionalProperties: false
          description: Canonical inclusive start and end IP addresses.
        cidrs:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          minItems: 1
          maxItems: 254
          description: Complete minimal CIDR list, sorted by network address, with no gaps, overlaps, or additional addresses.
        cidrCount:
          type: integer
          minimum: 1
          maximum: 254
        addressCount:
          type: string
          pattern: ^(0|[1-9][0-9]*)$
          description: Exact number of addresses as a base-10 string, including network and broadcast addresses.
      required:
      - family
      - range
      - cidrs
      - cidrCount
      - addressCount
      additionalProperties: false
    CidrCoverRequest:
      type: object
      properties:
        inputs:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          minItems: 1
          maxItems: 1000
          description: IP addresses or CIDRs from one address family. Surrounding whitespace is ignored during parsing; CIDRs with host bits are normalized.
      required:
      - inputs
      additionalProperties: false
    CidrSubtractResult:
      type: object
      properties:
        family:
          type: string
          enum:
          - ipv4
          - ipv6
        normalizedInclude:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          minItems: 1
          maxItems: 1000
        normalizedExclude:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          maxItems: 1000
        cidrs:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          maxItems: 10000
        includedAddressCount:
          type: string
          pattern: ^(0|[1-9][0-9]*)$
          description: Exact number of addresses as a base-10 string, including network and broadcast addresses.
        removedAddressCount:
          type: string
          pattern: ^(0|[1-9][0-9]*)$
          description: Exact number of addresses as a base-10 string, including network and broadcast addresses.
        remainingAddressCount:
          type: string
          pattern: ^(0|[1-9][0-9]*)$
          description: Exact number of addresses as a base-10 string, including network and broadcast addresses.
      required:
      - family
      - normalizedInclude
      - normalizedExclude
      - cidrs
      - includedAddressCount
      - removedAddressCount
      - remainingAddressCount
      additionalProperties: false
    CidrCoverResult:
      type: object
      properties:
        family:
          type: string
          enum:
          - ipv4
          - ipv6
        normalizedInputs:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 64
          minItems: 1
          maxItems: 1000
          description: Canonical CIDRs in input order. Individual addresses become /32 or /128. Duplicates are retained here.
        cidr:
          type: string
          minLength: 1
          maxLength: 64
          description: The smallest single canonical CIDR containing every input address.
        range:
          type: object
          properties:
            first:
              type: string
              minLength: 1
            last:
              type: string
              minLength: 1
          required:
          - first
          - last
          additionalProperties: false
        inputAddressCount:
          type: string
          pattern: ^(0|[1-9][0-9]*)$
          description: Number of distinct addresses in the union of the inputs.
        coveredAddressCount:
          type: string
          pattern: ^(0|[1-9][0-9]*)$
          description: Number of all addresses in the resulting CIDR.
        additionalAddressCount:
          type: string
          pattern: ^(0|[1-9][0-9]*)$
          description: Covered address count minus input address count.
      required:
      - family
      - normalizedInputs
      - cidr
      - range
      - inputAddressCount
      - coveredAddressCount
      - additionalAddressCount
      additionalProperties: false
    RangeToCidrsRequest:
      type: object
      properties:
        start:
          type: string
          minLength: 1
          maxLength: 64
          description: Inclusive start IP address. Use IPv4 or IPv6 without a CIDR prefix; surrounding whitespace is ignored.
        end:
          type: string
          minLength: 1
          maxLength: 64
          description: Inclusive end IP address, in the same family and at or after start. Endpoints are never silently swapped.
      required:
      - start
      - end
      additionalProperties: false