# Text Similarity API

> Text Similarity compares two text strings and calculates their percentage match score. It returns case-insensitive and case-sensitive similarity scores plus the count and proportion of differing words.

**Endpoint:** `POST https://api.apiverve.com/v1/textsimilarity`  
**Category:** Text Processing  
**Cost:** 2 credits per call  
**Canonical page:** https://apiverve.com/marketplace/textsimilarity

## Overview

Text Similarity works by comparing the two texts and calculating the similarity score based on various factors. It returns the similarity score in a structured format.

## 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/textsimilarity" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text1":"I'\''m so excited that tomorrow is going to be sunny! Can'\''t wait!","text2":"We'\''re pretty excited about the weather tomorrow. It'\''s going to be sunny!"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `text1` | string | Yes | The first text to compare. Must be less than 1000 characters |
| `text2` | string | Yes | The second text to compare. Must be less than 1000 characters |

## Response fields

- `similarity` — number · Case-insensitive similarity score between the two texts, as a percentage from 0 to 100 where 100 means the texts are identical
- `similarityCaseSensitive` — number · Case-sensitive similarity score between the two texts, as a percentage from 0 to 100, where differing letter casing counts against the score
- `semanticSimilarity` — number · How close the two texts are in meaning, as a percentage from 0 to 100, from a sentence-embedding model. Rewordings with no words in common score high; texts on unrelated topics score near 0. It measures topic and meaning, not sentiment, so opposite opinions about the same thing still score high. Null if the model was unavailable for this request · (premium)
- `difference` — object
  - `difference.count` — number · Number of words that appear in only one of the two texts, counted across both directions (case-insensitive, ignoring punctuation)
  - `difference.percentage` — number · Percentage of words, out of the combined word count of both texts, that appear in only one of the two texts (case-insensitive, ignoring punctuation)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "similarity": 45.83,
    "similarityCaseSensitive": 47.22,
    "semanticSimilarity": 88.33,
    "difference": {
      "count": 7,
      "percentage": 58.33
    }
  }
}
```

## Use cases

- **Plagiarism Screening** — Educators check student assignment submissions against reference essays to catch paraphrased or near-identical passages using case-insensitive similarity scores.
- **Catalog Deduplication** — To merge duplicate inventory listings, marketplace operators evaluate difference percentages across submitted product titles.
- **Support Ticket Clustering** — Helpdesk systems group incoming user inquiries with existing knowledge base answers when match percentages cross predefined thresholds.
- **Translation Revision Tracking** — When editors revise translated copy, localization teams compute case-sensitive similarity to track how much phrasing changed between drafts.

## SDKs

- **npm** — `npm install @apiverve/textsimilarity` (https://www.npmjs.com/package/@apiverve/textsimilarity)
- **PyPI** — `pip install apiverve-textsimilarity` (https://pypi.org/project/apiverve-textsimilarity/)
- **NuGet** — `dotnet add package APIVerve.API.TextSimilarity` (https://www.nuget.org/packages/APIVerve.API.TextSimilarity)
- **Source** — https://github.com/apiverve/textsimilarity-api

## More

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