---
title: "Parse, compare, sort and bump Semantic Versions, and test versions against npm-style ranges."
method: POST
path: "/api/v1/semver"
tags: ["Formatters & Validators"]
---

# Parse, compare, sort and bump Semantic Versions, and test versions against npm-style ranges.

`POST /api/v1/semver`

## Request

- Base URL: `https://programmes.net`
- URL: `https://programmes.net/api/v1/semver`
- Auth: none declared

SemVer Calculator. Operations: `parse` — Parse a SemVer 2.0.0 version into its components. `compare` — Compare two versions by SemVer precedence (-1, 0 or 1). `satisfies` — Test whether a version satisfies a range (^, ~, x, hyphen, ||). `max-satisfying` — Find the highest and lowest versions in a list that satisfy a range. `explain-range` — Desugar a range into plain comparators (e.g. ^1.2.3 → >=1.2.3 <2.0.0-0). `sort` — Sort versions by SemVer precedence; invalid entries are listed separately. `bump` — Increment a version like `npm version <release>`.

## Request body

- union
  - SemverParse: Parse a SemVer 2.0.0 version into its components.
    - `operation` 'parse', required
    - `input` string: A version, e.g. "v1.4.0-beta.2+build.7".
    - `options` object
  - SemverCompare: Compare two versions by SemVer precedence (-1, 0 or 1).
    - `operation` 'compare', required
    - `input` string: The first version.
    - `options` object, required
      - `other` string, required: The version to compare with.
  - SemverSatisfies: Test whether a version satisfies a range (^, ~, x, hyphen, ||).
    - `operation` 'satisfies', required
    - `input` string: The version to test.
    - `options` object, required
      - `range` string, required: An npm-style range, e.g. "^1.2.0 || ~2.1".
      - `includePrerelease` boolean: Let prerelease versions match ranges that do not name a prerelease.
  - SemverMaxSatisfying: Find the highest and lowest versions in a list that satisfy a range.
    - `operation` 'max-satisfying', required
    - `input` string: Versions separated by newlines, commas or spaces.
    - `options` object, required
      - `range` string, required: An npm-style range.
  - SemverExplainRange: Desugar a range into plain comparators (e.g. ^1.2.3 → >=1.2.3 <2.0.0-0).
    - `operation` 'explain-range', required
    - `input` string: An npm-style range.
    - `options` object
  - SemverSort: Sort versions by SemVer precedence; invalid entries are listed separately.
    - `operation` 'sort', required
    - `input` string: Versions separated by newlines, commas or spaces.
    - `options` object
      - `order` 'asc' | 'desc': Sort order.
  - SemverBump: Increment a version like `npm version <release>`.
    - `operation` 'bump', required
    - `input` string: The current version.
    - `options` object, required
      - `release` 'major' | 'minor' | 'patch' | 'premajor' | 'preminor' | 'prepatch' | 'prerelease', required: Which part to bump.
      - `preid` string: Prerelease identifier, e.g. "beta" or "rc".

## Response `200`

The operation ran.

- object
  - `ok` unknown, required
  - `tool` 'semver', required
  - `operation` 'parse' | 'compare' | 'satisfies' | 'max-satisfying' | 'explain-range' | 'sort' | 'bump', required
  - `result` unknown, required

## Other responses

- `400`: The request is not valid (https://programmes.net/api#invalid-request); The tool has no such operation (https://programmes.net/api#unknown-operation)
- `404`: No such tool (https://programmes.net/api#unknown-tool)
- `413`: The request or its input is too large (https://programmes.net/api#content-too-large)
- `415`: The body must be JSON (https://programmes.net/api#unsupported-media-type)
- `422`: An option is missing, of the wrong type or out of range (https://programmes.net/api#invalid-options); This call needs more CPU than one API call may use (https://programmes.net/api#refused); The operation could not process the input (https://programmes.net/api#tool-error)
- `429`: Too many requests (https://programmes.net/api#rate-limited)
- `500`: Internal error (https://programmes.net/api#internal-error)

---

[API](https://skmtc.dev/programmes/apis/programmes-net-api.md) · [All operations](https://skmtc.dev/programmes/apis/programmes-net-api/llms.txt) · [OpenAPI document](https://skmtc.dev/programmes/apis/programmes-net-api/revisions/aa939784a2e6?raw)
