API Almanac
API reference › Semver

Parse and sort semantic versions, compare two, and test them against an npm-style range

GET/v1/semver

GET/v1/semver

Parse and sort semantic versions, compare two, and test them against an npm-style range

PARAMETERS
versionsquery · stringREQUIRED
Comma-separated versions
e.g. 1.2.3, 1.10.0, 1.2.3-beta.1, 2.0.0-rc.1, v0.9.9
rangequery · string
Range to test, e.g. ^1.2.0, ~1.2.3, >=1.0.0 <2.0.0, 1.x, 1.2.3 - 1.9.0, >=2 || <1
e.g. ^1.2.0
comparequery · string
Two versions separated by a comma to compare directly
e.g. 1.10.0,1.9.9
In the full reference
REQUEST
curl "https://api.apialmanac.com/v1/semver?versions=1.2.3%2C+1.10.0%2C+1.2.3-beta.1%2C+2.0.0-rc.1%2C+v0.9.9" \
  -H "X-API-Key: YOUR_KEY"
RESPONSE
200OK
{
  "versions": [
    {
      "input": "1.10.0",
      "valid": true,
      "version": "1.10.0",
      "major": 1,
      "minor": 10,
      "patch": 0,
      "prerelease": [],
      "build": []
    },
    {
      "input": "1.2.3-beta.1",
      "valid": true,
      "version": "1.2.3-beta.1",
      "major": 1,
      "minor": 2,
      "patch": 3,
      "prerelease": [
        "beta",
        "1"
      ],
      "build": []
    }
  ],
  "sorted": [
    "1.2.3-beta.1",
    "1.10.0"
  ],
  "lowest": "1.2.3-beta.1",
  "highest": "1.10.0",
  "range": {
    "input": "^1.2.0",
    "matches": [
      "1.10.0"
    ],
    "highest_match": "1.10.0"
  },
  "compare": {
    "a": "1.10.0",
    "b": "1.9.9",
    "result": 1,
    "relation": "1.10.0 > 1.9.9"
  }
}
Try it — sign in first
Runs on a sandbox key: 200 requests a month. Your real key is for production.