deterministic
no-api-key
code
versions
semver

Semver parser: parse and compare versions, check range satisfaction

Semver parser and comparator: parse a semantic version into major, minor, patch, prerelease and build parts; compare two versions by precedence including prerelease ordering; or test whether a version satisfies a range expression using caret, tilde, hyphen, x-ranges and comparator sets. Returns the parsed structure, the comparison result and the reason a range did not match.

Output (data): parse: valid, major, minor, patch (integers; null when the version is invalid), prerelease [], build [], is_prerelease, canonical (string|null, null when invalid), reason (string|null: why an invalid version failed; null when valid). compare: result (-1|0|1), a, b, precedence_note. satisfies: satisfies, range (normalised by node-semver; the trimmed input when that is empty, as for * and x), comparators [], reason. sort: sorted [], invalid [].

Deterministic: identical input returns identical output, so the response is served with Cache-Control: private, max-age=31536000, immutable (the paying client may cache it indefinitely; shared caches must not, because the response is paid).

Price: $0.05 USDC per call (x402, Base). Route contract version 1.0.0. Docs: https://api.duoleads.com/docs#code-semver

get/v1/code/semver

Request

  • Base URL: https://api.duoleads.com
  • URL: https://api.duoleads.com/v1/code/semver
  • Auth: none declared

Query parameters

op'parse' | 'compare' | 'satisfies' | 'sort'

parse (default), compare, satisfies or sort. Accepted: parse, compare, satisfies, sort.

versionstring

Version to parse (op=parse) or test (op=satisfies). Accepted: at most 256 characters.

astring

First version for op=compare. Accepted: at most 256 characters.

bstring

Second version for op=compare. Accepted: at most 256 characters.

rangestring

Range expression for op=satisfies, e.g. ^1.2.0. Accepted: at most 256 characters.

versionsstring

Comma-separated versions for op=sort, at most 100. Accepted: at most 100 versions.

Response

Paid and settled. data is route-specific; a route that judges its input returns 200 with data.valid: false for a bad value.

okunknown required
route'/v1/code/semver' required
version'1.0.0' required

Changes

No recorded changes to this operation across all 1 revision of this API.