# Text Similarity: Hamming Distance

> Text Similarity: Hamming Distance is a paid API for AI agents from text-similarity.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-21).

Computes the Hamming distance between two equal-length strings, returning the count and positions of differing characters.

## Facts

- Endpoint: GET https://text-similarity.x402tookit.com/hamming?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-21
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/text-similarity-hamming-distance-08fca984
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_2GM87BRIQ-D6_TMZlQ9wk

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability text-similarity-hamming-distance-08fca984
```

Example prompt: What's the Hamming distance between 'karolin' and 'kathrin'? Give me the count and exact positions where they differ, case-insensitively.

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

Hamming distance between two equal-length strings (text or binary), with the differing positions. Unequal lengths are undefined.

## Output

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.

## Request schema (JSON Schema)

```json
{
 "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"
       ]
      }
     }
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/text-similarity-hamming-distance-08fca984/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from text-similarity.x402tookit.com](https://www.zero.xyz/host/text-similarity.x402tookit.com/llms.txt)
