The Text Similarity API computes the similarity score between two pieces of text. It uses state-of-the-art NLP machine learning models to first embed (see our Embddings API) the texts into 768-dimension vectors, and then computes the cosine similarity between the two vectors.
https://api.api-ninjas.com/v1/textsimilarity
Returns a similarity score between 0 and 1 (1 is similar and 0 is dissimilar) of two given texts.
text_1
requiredFirst input text. Maximum 5000 characters.
text_2
requiredSecond input text. Maximum 5000 characters.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/textsimilarity
Headers
X-Api-Key
Log in or sign up to get your API Key
1
2
3
{
"similarity": 0.7749438285827637
}
1
2
3
4
curl -X POST "https://api.api-ninjas.com/v1/textsimilarity" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text_1": "This is an example sentence.", "text_2": "This is just another example sentence."}'
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.