{"uid":"cap_2GM87BRIQ-D6_TMZlQ9wk","slug":"text-similarity-hamming-distance-08fca984","name":"Text Similarity: Hamming Distance","description":"Hamming distance between two equal-length strings (text or binary), with the differing positions. Unequal lengths are undefined.","url":"https://text-similarity.x402tookit.com/hamming?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 string, up to 2000 characters"},"b":{"type":"string","description":"Second string of the same length, 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"]},"source":{"type":["null","string"]},"lengthA":{"type":["null","number"]},"lengthB":{"type":["null","number"]},"reasons":{"type":["array","null"]},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"distance":{"type":["null","number"]},"positions":{"type":["array","null"],"items":{"type":"number"}},"disclaimer":{"type":["null","string"]},"ignoreCase":{"type":["boolean","null"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"similarity":{"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_SmvekhA7xOfKfhGzT2vss","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 Hamming distance between two equal-length strings, returning the count and positions of differing characters.","exampleAgentPrompt":"What's the Hamming distance between 'karolin' and 'kathrin'? Give me the count and exact positions where they differ, case-insensitively.","exampleUseCases":[{"title":"DNA sequence mutation detection","prompt":"Compare these two equal-length DNA sequences and tell me how many positions differ and where: 'AGCTTAGCTA' and 'AGCTTCGCCA'"},{"title":"Error detection in transmitted codewords","prompt":"I sent the binary codeword '10110101' and received '10010111' — how many bit positions are different and which ones?"},{"title":"Password similarity check","prompt":"Check how many character positions differ between the strings 'P@ssw0rd1!' and 'P@sSw1rd1!' — use case-insensitive comparison and show me the differing positions."}],"resultDescription":"Returns the Hamming distance (integer count of differing positions), an array of zero-based or one-based position indices where characters differ, a normalized similarity score (0–1), the lengths of both input strings, a summary string, and metadata such as whether case was ignored.","failureModes":["Strings of unequal length return an error or undefined result — both inputs must be the same length","Strings exceeding 2000 characters are rejected","Missing required query parameters 'a' or 'b' return a validation error","Payment failure returns HTTP 402 and the call is not executed"],"whenToPreferThis":"Use this endpoint when you need a positional, character-level comparison of two equal-length strings, such as binary codewords, DNA sequences, fixed-width codes, or checksums. It is the right choice when you specifically need to know which positions differ, not just an overall edit distance. Prefer Levenshtein for strings of different lengths, or Jaro-Winkler for fuzzy name matching.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-21T07:20:18.359Z","isFirstParty":false,"canonicalSlug":"text-similarity-hamming-distance-08fca984"}