---
title: "Semver parser: parse and compare versions, check range satisfaction"
method: GET
path: "/v1/code/semver"
tags: ["deterministic", "no-api-key", "code", "versions", "semver"]
---

# Semver parser: parse and compare versions, check range satisfaction

`GET /v1/code/semver`

## Request

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

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

## Query parameters

- `op` 'parse' | 'compare' | 'satisfies' | 'sort'
- `version` string
- `a` string
- `b` string
- `range` string
- `versions` string

## Response `200`

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

- object
  - `ok` unknown, required
  - `route` '/v1/code/semver', required
  - `version` '1.0.0', required
  - `data` object, required: 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 [].
    - `valid` boolean
    - `major` integer, nullable
    - `minor` integer, nullable
    - `patch` integer, nullable
    - `prerelease` union[]
      - union
        - number
        - string
    - `build` string[]
    - `is_prerelease` boolean
    - `canonical` string, nullable
    - `reason` string, nullable
    - `satisfies` boolean
    - `range` string
    - `comparators` string[]
    - `sorted` string[]
    - `invalid` string[]
    - `result` integer
    - `a` string
    - `b` string
    - `precedence_note` string
  - `meta` Meta, required
    - `disclaimer` string, required: Legal short disclaimer, identical on every response.
    - `request_id` string, required: ULID.
    - `computed_at` string, date-time, required: RFC 3339 UTC with milliseconds.
    - `price_usd` string, required: Decimal string, "0.05".
    - `deterministic` boolean, required
    - `sources` object[]: Present only on routes that read a vendored dataset: the exact edition that answered.
      - `id` string, required
      - `version` string, required
      - `published` string, required
      - `attribution` string
      - `licence` string

## Other responses

- `400`: MISSING_PARAM, INVALID_PARAM or UNSUPPORTED_VALUE. Not charged: validation runs before the paywall.
- `402`: Payment required. No valid PAYMENT-SIGNATURE was supplied: read the base64 PAYMENT-REQUIRED header (or this body) for the price ($0.05 = 50000 atomic USDC on eip155:8453), sign an EIP-3009 authorization and retry. Also returned when settlement is declined (PAYMENT_FAILED). Nothing is charged on a 402.
- `404`: NOT_FOUND: unknown path. Not charged.
- `405`: METHOD_NOT_ALLOWED: only GET and HEAD are served. Not charged.
- `413`: INPUT_TOO_LARGE: a parameter exceeded its documented maximum length. Not charged.
- `500`: INTERNAL: a server bug. Not charged.

---

[API](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo.md) · [All operations](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/llms.txt) · [OpenAPI document](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/revisions/18790d59615e?raw)
