# Levenshtein Distance API

> Levenshtein Distance calculates the minimum number of single-character edits needed to transform one string into another.

**Endpoint:** `POST https://api.apiverve.com/v1/levenshteindistance`  
**Category:** Text Processing  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/levenshteindistance

## Overview

A Levenshtein distance API for measuring how different two strings are. Send any two strings and get back the edit distance between them, a similarity percentage from 0 to 100 and a plain match level you can act on without choosing thresholds yourself. Ideal for spell checking, fuzzy matching, plagiarism detection, and any application requiring string similarity measurement.

Edit distance is the number of single-character insertions, deletions and substitutions needed to turn one string into the other: "kitten" and "sitting" are three edits apart. That makes it a practical way to catch near-duplicate records, match a typed name against a list, suggest the closest valid command or product code, and flag text that has been lightly altered.

Every plan, including the Free plan, returns the distance, the similarity percentage and the match level. Paid plans also echo both input strings and return their lengths, which is useful when you log comparisons or batch them and need each result to carry its own context.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/levenshteindistance" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"string1":"kitten","string2":"sitting"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `string1` | string | Yes | First string to compare (max 10,000 characters). length 0-10000 |
| `string2` | string | Yes | Second string to compare (max 10,000 characters). length 0-10000 |

## Response fields

- `distance` — number · The Levenshtein edit distance between the two strings
- `similarity` — number · Similarity percentage from 0 to 100
- `matchLevel` — string · Similarity level: exact, high, medium, low, or none
- `string1Length` — number · Length of the first string · (premium)
- `string2Length` — number · Length of the second string · (premium)
- `string1` — string · The first input string · (premium)
- `string2` — string · The second input string · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "distance": 3,
    "similarity": 57.14,
    "matchLevel": "medium",
    "string1Length": 6,
    "string2Length": 7,
    "string1": "kitten",
    "string2": "sitting"
  }
}
```

## Use cases

- **Spell Checking** — Calculate similarity between misspelled words and dictionary entries
- **Fuzzy Search** — Implement approximate string matching for search engines
- **Plagiarism Detection** — Measure text similarity for detecting copied content
- **Data Deduplication** — Identify near-duplicate records in databases

## SDKs

- **npm** — `npm install @apiverve/levenshteindistance` (https://www.npmjs.com/package/@apiverve/levenshteindistance)
- **NuGet** — `dotnet add package APIVerve.API.LevenshteinDistance` (https://www.nuget.org/packages/APIVerve.API.LevenshteinDistance)
- **Source** — https://github.com/apiverve/levenshteindistance-api

## More

- Full reference: https://docs.apiverve.com/ref/levenshteindistance
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
