{"uid":"cap_KQg0Nd3Rsbrv527_m6fAu","slug":"text-similarity-longest-common-subsequence-substring-lcs-94193c00","name":"Text Similarity: Longest Common Subsequence & Substring (LCS)","description":"Longest common subsequence and longest common substring of two texts, with their lengths and a 0 to 1 ratio.","url":"https://text-similarity.x402tookit.com/lcs?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":["a","b"],"properties":{"a":{"type":"string","description":"First text, up to 2000 characters"},"b":{"type":"string","description":"Second text, up to 2000 characters"},"ignoreCase":{"type":"boolean","description":"true to compare case-insensitively (default false)"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"asOf":{"type":["null","string"]},"ratio":{"type":["null","number"]},"source":{"type":["null","string"]},"lengthA":{"type":["null","number"]},"lengthB":{"type":["null","number"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"substring":{"type":["null","string"]},"disclaimer":{"type":["null","string"]},"ignoreCase":{"type":["boolean","null"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"subsequence":{"type":["null","string"]},"substringLength":{"type":["null","number"]},"substringStartA":{"type":["null","number"]},"substringStartB":{"type":["null","number"]},"subsequenceLength":{"type":["null","number"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","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.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_UqTBM_6KtoGNMeDGllprp","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes the longest common subsequence and longest common substring between two texts, returning their lengths, the actual sequences, start positions, and a 0-to-1 similarity ratio.","exampleAgentPrompt":"Find the longest common subsequence and substring between these two texts — 'The quick brown fox jumps over the lazy dog' and 'The slow brown fox leaped over a lazy cat' — and give me the similarity ratio, case-insensitively.","exampleUseCases":[{"title":"Plagiarism detection in student essays","prompt":"Compare these two essay excerpts and find their longest common subsequence and substring so I can see how much text is shared: first is 'Climate change is the defining challenge of our generation' and second is 'Climate change remains the defining challenge for our generation today'. Ignore case differences."},{"title":"Version diff for config file snippets","prompt":"I have two versions of a config snippet and I want to know their longest common substring and the similarity ratio — version A is 'server.host=localhost port=8080 debug=true' and version B is 'server.host=localhost port=9090 debug=false'."},{"title":"DNA or code sequence overlap analysis","prompt":"What is the longest common subsequence between 'ATCGTTAGCCTAG' and 'ATCGAAGCCTAG', and how long is it? Also give me the similarity ratio."}],"resultDescription":"Returns the longest common subsequence string and its length, the longest common substring string with its length and start positions in both input texts, the character lengths of both inputs, the ignoreCase setting used, and a 0-to-1 similarity ratio reflecting overall overlap. May also include a summary, verdict, reasons, and degraded/disclaimer flags.","failureModes":["Missing required query parameters 'a' or 'b' returns an error","Inputs exceeding 2000 characters may be rejected or truncated","Payment failure (x402 protocol) results in 402 Payment Required","Empty strings may yield zero-length results with ratio 0","Network timeout on large inputs close to the character limit"],"whenToPreferThis":"Choose this endpoint when you need classical sequence-level overlap metrics — specifically LCS subsequence and substring — rather than phonetic, edit-distance, or vector-space similarity. Ideal for detecting shared content spans, finding longest matching runs, or computing overlap ratios for document comparison pipelines where character-level alignment matters. Prefer sibling endpoints (Levenshtein, Dice, cosine) for edit-cost or set-overlap needs.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-21T12:39:35.021Z","isFirstParty":false,"canonicalSlug":"text-similarity-longest-common-subsequence-substring-lcs-94193c00"}