{"uid":"cap_TroGs9Kmyi4cdE0tB-h6p","slug":"duo-data-utilities-semantic-version-parser-comparator-ba21dd74","name":"Duo Data Utilities – Semantic Version Parser & Comparator","description":"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.","url":"https://api.duoleads.com/v1/code/semver?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":[],"properties":{"a":{"type":"string","maxLength":256,"description":"First version for op=compare."},"b":{"type":"string","maxLength":256,"description":"Second version for op=compare."},"op":{"enum":["parse","compare","satisfies","sort"],"type":"string","default":"parse","maxLength":64,"description":"parse (default), compare, satisfies or sort."},"range":{"type":"string","maxLength":256,"description":"Range expression for op=satisfies, e.g. ^1.2.0."},"version":{"type":"string","maxLength":256,"description":"Version to parse (op=parse) or test (op=satisfies)."},"versions":{"type":"string","maxLength":2048,"description":"Comma-separated versions for op=sort, at most 100."}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","required":["ok","route","version","data","meta"],"properties":{"ok":{"const":true},"data":{"type":"object","properties":{"a":{"type":"string"},"b":{"type":"string"},"build":{"type":"array","items":{"type":"string"}},"major":{"type":["integer","null"]},"minor":{"type":["integer","null"]},"patch":{"type":["integer","null"]},"range":{"type":"string"},"valid":{"type":"boolean"},"reason":{"type":["string","null"]},"result":{"type":"integer"},"sorted":{"type":"array","items":{"type":"string"}},"invalid":{"type":"array","items":{"type":"string"}},"canonical":{"type":["string","null"]},"satisfies":{"type":"boolean"},"prerelease":{"type":"array","items":{"type":["number","string"]}},"comparators":{"type":"array","items":{"type":"string"}},"is_prerelease":{"type":"boolean"},"precedence_note":{"type":"string"}}},"meta":{"type":"object","required":["request_id","computed_at","price_usd","deterministic","disclaimer"],"properties":{"sources":{"type":"array","items":{"type":"object","required":["id","version","published"]}},"price_usd":{"type":"string"},"disclaimer":{"type":"string"},"request_id":{"type":"string"},"computed_at":{"type":"string","description":"RFC 3339 UTC with milliseconds"},"deterministic":{"type":"boolean"}}},"route":{"const":"/v1/code/semver"},"version":{"type":"string"}}}}}}},"responseSchema":{"type":"json","example":{"ok":true,"data":{"build":["build","5"],"major":1,"minor":2,"patch":3,"valid":true,"reason":null,"canonical":"1.2.3-rc.1+build.5","prerelease":["rc",1],"is_prerelease":true},"meta":{"price_usd":"0.05","disclaimer":"Factual output of a deterministic computation over public data. Provided as is, with no warranty of accuracy, completeness or availability. Not investment, financial, legal, tax, medical or any other professional advice, and not a recommendation. Verify before relying on it. Terms: https://api.duoleads.com/terms","request_id":"01K6B7Q4ZC8H3F2M9WXR5TYN0D","computed_at":"2026-09-28T12:00:00.000Z","deterministic":true},"route":"/v1/code/semver","version":"1.0.0"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_pGqoGFEVEN6uagNWdJPEU","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Parse a semantic version string into its components, compare two versions by precedence, test whether a version satisfies a range expression, or sort a list of versions.","exampleAgentPrompt":"Parse the semver string '1.2.3-rc.1+build.5' and break it into its major, minor, patch, prerelease, and build parts.","exampleUseCases":[{"title":"Dependency range check for CI pipeline","prompt":"Check whether version 2.4.1 satisfies the semver range ^2.3.0 — I need to know if this package version is compatible before we deploy."},{"title":"Compare two release versions","prompt":"Compare semver versions 3.0.0-beta.2 and 3.0.0-alpha.10 and tell me which one takes precedence according to semver rules."},{"title":"Sort a list of release tags","prompt":"Sort these versions in order for me: 1.0.0, 2.0.0-alpha.1, 1.10.0, 1.9.3, 2.0.0 — I want to know the correct semver ordering from lowest to highest."}],"resultDescription":"Returns a JSON object with an 'ok' flag and a 'data' object whose shape depends on the operation: for 'parse', it includes major, minor, patch, prerelease array, build array, is_prerelease flag, valid flag, canonical form, and a reason field if invalid; for 'compare', it returns the comparison result; for 'satisfies', it returns a boolean and the reason a range did not match; for 'sort', it returns the ordered list. Also includes metadata such as request_id, computed_at timestamp, determinism flag, and price.","failureModes":["Invalid or malformed version string returns valid=false with a reason field explaining the parse failure","Missing required query parameters for the selected operation (e.g. no 'a' or 'b' for op=compare) returns an error","Range expression syntax errors for op=satisfies return an error describing the invalid range","More than 100 versions supplied to op=sort exceeds the limit and returns an error","Network or payment authorization failure returns a 402 or 5xx HTTP error"],"whenToPreferThis":"Choose this endpoint when you need deterministic, standards-compliant semantic version operations — parsing, comparison, range satisfaction, or sorting — without setting up a local semver library. It is especially useful in agentic pipelines that need to compare dependency versions, validate release tags against a range expression, or sort version lists from external sources, all via a simple HTTP GET with no runtime dependencies.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T03:04:51.750Z","isFirstParty":false,"canonicalSlug":"duo-data-utilities-semantic-version-parser-comparator-ba21dd74"}