Text Similarity Calculator API Integration Guide

Compare text meaning with a semantic similarity score. Use ranked text pairs for duplicate review, content matching, and search evaluation.

Try the live demoView API details →

Text Similarity Calculator API

Compare the meaning of two texts and receive a score from 0.00 to 1.00. Use it to prioritize possible duplicates, match related content, or review search results. A score is a comparison signal, not proof that two statements are equivalent.

View API details or try the Demo.

Send a text pair

Send POST https://api.gugudata.io/v1/text/similarity with an AppKey in the query string and the two texts in a JSON body. Keep your key on your server.

Parameter Location Requirement
appkey Query A valid application key.
content1 JSON Nonblank string, up to 5,000 Unicode code points.
content2 JSON Nonblank string, up to 5,000 Unicode code points.

Original spacing is preserved. Send one pair per request; there is no batch input parameter.

curl 'https://api.gugudata.io/v1/text/similarity?appkey=YOUR_APPKEY' \
  -H 'Content-Type: application/json' \
  --data '{"content1":"The weather is good today.","content2":"It is a sunny day."}'

Read the result

The following is an illustrative response. Scores can vary between requests; do not depend on this exact value.

{
  "dataStatus": {
    "requestParameter": "content1Length=26&content2Length=18",
    "statusCode": 100,
    "statusDescription": "Request successful.",
    "responseDateTime": "2026-09-08 10:00:00.000",
    "dataTotalCount": 1
  },
  "data": {
    "similarity": "0.85"
  }
}
Field Type Meaning
dataStatus.requestParameter string Input character counts, not the original texts.
dataStatus.statusCode integer 100 for success; -1 for a processing failure.
dataStatus.statusDescription string Human-readable status.
dataStatus.responseDateTime string Timestamp in yyyy-MM-dd HH:mm:ss.SSS format.
dataStatus.dataTotalCount integer 1 on success, 0 on processing failure.
data object or null Score object on success; null on processing failure.
data.similarity string Decimal score from 0.00 to 1.00, with two decimal places.

Convert the score to a number only after checking the business status:

const response = await fetch(
  'https://api.gugudata.io/v1/text/similarity?appkey=' + encodeURIComponent(appkey),
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ content1, content2 })
  }
);
const result = await response.json();
if (!response.ok || result.dataStatus?.statusCode !== 100) {
  throw new Error('Text comparison failed');
}
const similarity = Number(result.data.similarity);

Handle errors

The existing contract returns HTTP 200 for both a successful comparison and a processing failure. Always inspect dataStatus.statusCode; never interpret a failed comparison as a zero score.

HTTP status Meaning
200 Business status 100 with a score, or -1 with data: null.
400 Invalid JSON, missing or blank text, or an input exceeding the limit.
401 Missing or invalid application key.
403 Access is not permitted.
429 Request or usage limit reached.
500 Unexpected service error.

Avoid rapid repeated requests after a failure. Log status and timing rather than private text or credentials.

Try the Demo

GET https://api.gugudata.io/v1/text/similarity/demo compares these fixed texts:

  • Text similarity aims to identify whether two pieces of text are semantically similar
  • Text similarity can check the semantic similarity between two texts

The Demo performs a comparison when its 15-minute cache is empty. A successful result includes X-GuGuData-Demo-Mode: live or cached and X-GuGuData-Generated-At. Failed comparisons are not cached. Use the formal endpoint for your own text pairs.

Choose thresholds for your workflow

Evaluate representative examples before setting a match threshold. Short text, negation, specialized terminology, and missing context can affect the result. Use human review for consequential decisions; this API does not verify facts, detect copyright infringement, or guarantee plagiarism detection.

For the full contract, see the OpenAPI specification. Related tools include language detection and Chinese script conversion.