Skip to content
moxon home

Semantic Versioning

The /semver endpoint parses, bumps, and compares semantic versions following the semver.org specification.

gethttps://api.moxon.dev/v6/semver

How it works?

A version must match the official grammar MAJOR.MINOR.PATCH, optionally followed by -prerelease and +build. Leading zeros are rejected, so 01.2.3 is invalid.

Comparison follows semver precedence: numeric parts first, then the prerelease. A version carrying a prerelease ranks below the same version without one, numeric prerelease identifiers are compared as numbers (alpha.2 is lower than alpha.10), and build metadata is ignored entirely.

A bump resets the lower parts to zero and drops both the prerelease and the build metadata, so 1.0.0-alpha+build.1 bumped on patch gives 1.0.1.

A + sign decodes as a space in a query string, so the API restores it before parsing — build metadata can be sent as-is or percent-encoded.

Try itget/v6/semver

Parameters

  • versionstringrequired

    Version to work with (e.g. 1.2.3-beta.1+build.42)

  • action"parse" | "bump" | "compare"optional

    Action to perform: parse, bump or compare. Default: parse

  • part"major" | "minor" | "patch"optional

    bump only: part to increment, major, minor or patch. Default: patch

  • otherstringconditional

    Second version to compare against (required for compare)

Available Actions

ActionDescription
parseSplits the version into its components
bumpIncrements part and resets the lower parts to zero
compareCompares version against other using semver precedence

Response Fields

parse action:

  • versionstring

    The original input version

  • majornumber

    Major number

  • minornumber

    Minor number

  • patchnumber

    Patch number

  • prereleasestring|null

    Prerelease identifiers without the leading -, null if absent

  • buildstring|null

    Build metadata without the leading +, null if absent

bump action:

  • versionstring

    The original input version

  • actionstring

    bump

  • partstring

    Part that was incremented

  • resultstring

    The bumped version

compare action:

  • versionstring

    The original input version

  • actionstring

    compare

  • otherstring

    The version compared against

  • resultnumber

    -1 if version is lower, 0 if equal, 1 if higher

  • descriptionstring

    Human-readable comparison (e.g. 1.2.3 < 1.3.0)

Code Examples

Error Handling

If parameters are missing or invalid, the API will return an error:

  • 400Please provide a version (?version={version})The version parameter is missing
  • 400Action must be one of: parse, bump, compareThe action value is not valid
  • 400Version must be 256 characters or fewerThe version or other value exceeds the maximum length
  • 400Invalid semver versionThe version or other value does not match the semver grammar
  • 400Part must be one of: major, minor, patchThe part value is not valid for bump
  • 400Please provide a second version (&other={version})The other parameter is missing for compare