Semver API

Parse and validate semantic versions, compare them, check npm-style ranges (^, ~, x, ||), sort lists and compute the next major / minor / patch / pre-release.

GETPOSThttps://apibox.io.vn/v1/semver
Developer utilities▶ Try it online

The semver API applies the rules of npm’s semver package, the reference implementation of Semantic Versioning 2.0.0. With version it parses a version (major, minor, patch, pre-release and build parts), compares it with compare= (lower / higher / equal and which part differs), tests it against a range such as ^1.2.0, ~3.4, >=2 <3, 1.x || 2.x or 1.2.3 - 2.0.0, and lists the next version for every release type.

With versions (an array or a comma-separated list) it sorts them, reports invalid entries, returns the latest and latest stable version and, with a range, the versions that satisfy it and the highest and lowest matches, which is how package managers pick a version.

coerce=true turns loose input such as v2, 1.2 or release-3.4.1 into a valid version; pre-releases only match ranges that mention them unless include_prerelease=true.

Parameters

NameInTypeRequiredDefault
versionquery|bodystringnoA version to parse.
comparequery|bodystringnoAnother version to compare with.
rangequery|bodystringnonpm range, e.g. ^1.2.0.
versionsquery|bodystringnoList to sort / filter (array or comma-separated).
bumpquery|bodystringnomajor, minor, patch, premajor, preminor, prepatch, prerelease.
coercequery|bodybooleannofalseAccept loose input (v2, 1.2).
include_prereleasequery|bodybooleannofalseLet ranges match pre-releases.

Example

curl "https://apibox.io.vn/v1/semver?versions=1.0.0,2.0.0-rc.1,1.10.0,1.2.0&range=>=1.2 <2" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "count": 4,
  "sorted": [
    "1.0.0",
    "1.2.0",
    "1.10.0",
    "2.0.0-rc.1"
  ],
  "invalid": [],
  "latest": "2.0.0-rc.1",
  "latest_stable": "1.10.0",
  "range": ">=1.2 <2",
  "normalized_range": ">=1.2.0 <2.0.0-0",
  "satisfying": [
    "1.10.0",
    "1.2.0"
  ],
  "max_satisfying": "1.10.0",
  "min_satisfying": "1.2.0"
}

Use cases

  • Update checks in apps and CLIs
  • Release automation: compute the next version
  • Dependency dashboards: which versions satisfy a range
  • Sort tags and releases correctly (1.10 after 1.9)

FAQ

What does ^1.2.3 allow?

Any version >=1.2.3 and <2.0.0. For 0.x versions the caret is stricter: ^0.2.3 means >=0.2.3 <0.3.0.

Why does 2.0.0-rc.1 not satisfy >=1.0.0?

By npm rules pre-releases only match comparators that have a pre-release on the same version. Use include_prerelease=true to include them.

Why is 1.10.0 after 1.9.0?

Each part is compared as a number, unlike plain string sorting.

Related APIs

Start with 1,000 free requests every month. Get free API key →