---
title: Compare and Rank Text Similarity API
slug: compute-text-similarity
url: https://apyhub.com/dosvak/service/compute-text-similarity
provider: Dosvak LLC
categories: [Artificial Intelligence]
tags: [text-similarity, semantic-search, cosine-similarity, embeddings, ranking]
auth: api_key
---

# Compare and Rank Text Similarity API

Compare two texts with a 0-1 similarity score, or rank candidate texts against a query by semantic relevance.

## Endpoints

| Method | Path | Description | Atoms |
| --- | --- | --- | --- |
| POST | `` | What it does Computes a cosine similarity score between two input texts using sentence embeddings.… | 10 |
| POST | `/rank` | What it does Ranks a list of candidate texts by their semantic similarity to a query, returning the… | 10 |

## About

## What it does
Text Similarity compares two pieces of text and returns a cosine similarity score between 0 and 1. Send `text1` and `text2` in the request body, and get both texts back along with a `similarity` value.

Use it when you need a fast semantic comparison instead of exact string matching. It is useful for duplicate detection, paraphrase checks, clustering short content, or measuring how closely a generated answer matches a reference sentence.

The service also includes a ranking endpoint for semantic search. Send a `query` string and an array of `candidates`, and it returns the `query` plus a `ranked` list of candidate objects ordered by score, highest first. Each ranked item includes the candidate `text` and its `score`, which makes it straightforward to surface the best match in a UI or downstream workflow.

Text Similarity is a good fit when you want lightweight text relevance scoring without building your own embedding pipeline.

## Usage

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/dosvak/service/compute-text-similarity
