# Near-Duplicate Content Finder (MinHash + SimHash) (`freecamp008/near-duplicate-finder`) Actor

Find duplicate and near-duplicate pages and texts at scale. Fetches URLs, strips boilerplate, clusters similar content with MinHash LSH and SimHash, and flags the canonical version. No external APIs.

- **URL**: https://apify.com/freecamp008/near-duplicate-finder.md
- **Developed by:** [Camp8 fr0](https://apify.com/freecamp008) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 document analyzeds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Near-Duplicate Content Finder: Detect Duplicate Pages & Texts with MinHash + SimHash

**Near-Duplicate Content Finder** detects **duplicate and near-duplicate content** across web pages and raw texts. Give it a list of URLs, a list of texts or a whole dataset (e.g. the output of a crawler), and it groups similar documents into **clusters**, flags the **canonical version** of each cluster, and lists every duplicate with its **similarity score**. It uses the same algorithms search engines use: **MinHash with LSH banding** (Jaccard similarity of word shingles) and **64-bit SimHash** (Hamming distance). It scales to **50,000+ documents in about a minute** with no O(n²) comparisons. Everything runs inside the Actor: no external APIs, no LLM costs.

### What does Near-Duplicate Content Finder do?

- 🌐 **Fetches web pages** and **strips boilerplate** (navigation, header, footer, sidebars, cookie banners, scripts, styles). It prefers `<article>` / `<main>`, or uses your own CSS selector.
- 🧮 **MinHash + LSH**: estimates Jaccard similarity on k-word shingles (default k=5, 128 permutations). Bands and rows are tuned automatically for at least 99.5% recall at your threshold.
- ✅ **Exact verification**: every LSH candidate pair is checked with the **exact Jaccard similarity** of the shingle sets, so reported scores are exact, not estimates.
- 🔢 **64-bit weighted SimHash** on word 3-grams, with bit-sampling LSH. It tolerates scattered small edits (typos, synonyms, re-wording).
- 🧩 **Clusters** near-duplicates (union-find) and marks one **canonical** document per cluster (the longest, or the first in input order).
- 📦 **Cluster summary JSON** is saved to the key-value store (`CLUSTERS`), ready to download.
- ⚡ **Scales**: identical documents are collapsed first, and candidate search is sub-quadratic. 10k documents take about 8 s; 50k documents (3.6 KB each) take about 53 s with a peak of about 680 MB RAM.
- 🔌 **HTTP API (Standby mode)**: POST your texts and get clusters back in one request.

### Use cases

- **SEO duplicate content audit**: find pages on your site (or across mirrors) that Google may treat as duplicates, and pick the canonical URL
- **Scraped data deduplication**: clean product listings, job ads, real-estate ads or news articles that were re-posted with tiny changes
- **Plagiarism and content-reuse detection** across articles, product descriptions or student submissions
- **RAG / LLM dataset cleaning**: remove near-duplicate chunks before embedding or fine-tuning
- **Syndication monitoring**: find where your content was republished
- **E-commerce catalogue hygiene**: detect copy-pasted product descriptions across SKUs

### How to use it

1. Click **Try for free**.
2. Paste **URLs**, and/or **texts** (strings or `{"id", "text"}` objects), and/or pick a **dataset** (set its text field, e.g. `text` for Website Content Crawler).
3. Choose the **method** (`both` is recommended) and the **similarity threshold** (0.8 by default).
4. Click **Start**. Each document becomes a row in the **Documents** view with its `clusterId`, `isCanonical`, and its duplicates. The full cluster summary is in the key-value store record `CLUSTERS` (linked in the run's **Output** tab).

#### Call it as an HTTP API (Standby mode)

```bash
## GET with query parameters (arrays are comma-separated)
curl "https://<your-standby-url>/?urls=https://example.com,https://example.org,https://example.net" \
  -H "Authorization: Bearer <APIFY_TOKEN>"

## POST with a JSON body: the main Standby use case (long texts)
curl -X POST "https://<your-standby-url>/" \
  -H "Authorization: Bearer <APIFY_TOKEN>" -H "Content-Type: application/json" \
  -d '{"texts":[{"id":"a","text":"First long article..."},{"id":"b","text":"Second long article..."}],"method":"both","similarityThreshold":0.8}'
```

Response: `{ "count": 2, "items": [ ...one result per document... ] }`

Use POST for texts: GET array parameters are split on commas, so a text containing commas must be sent as a JSON array (`texts=["a, b","c"]`).

You can also run it through the Apify API (`run-sync-get-dataset-items`), the Apify MCP server, Make, Zapier, n8n and other integrations. **AI agents can pay per call with x402 (USDC)** through Apify's agentic payments, without needing an Apify account.

### Input example

```json
{
  "urls": ["https://example.com", "https://example.org", "https://example.net", "https://www.iana.org/help/example-domains"],
  "texts": [
    { "id": "product-a", "text": "Our stainless steel water bottle keeps drinks cold for 24 hours..." },
    { "id": "product-a-copy", "text": "Our stainless-steel water bottle keeps drinks cold for 24 hours!..." }
  ],
  "method": "both",
  "similarityThreshold": 0.8,
  "shingleSize": 5,
  "numPermutations": 128,
  "lowercase": true,
  "stripPunctuation": true,
  "stripNumbers": false,
  "canonicalStrategy": "longest",
  "maxConcurrency": 10
}
```

| Field | Description |
|---|---|
| `urls` | Web pages to fetch and compare |
| `texts` | Raw texts: strings or `{"id", "text"}` objects |
| `datasetId` + `datasetTextField` / `datasetIdField` | Compare the items of an existing dataset (best for 10k-50k+ documents) |
| `method` | `both` (default), `minhash` (exact Jaccard), `simhash` (Hamming) |
| `similarityThreshold` | 0.3-1.0, default 0.8 |
| `shingleSize` | Words per shingle (default 5; use 2-3 for short texts) |
| `numPermutations` | MinHash hash functions (default 128) |
| `simhashMaxDistance` | Optional override of the max Hamming distance (default derived from the threshold: 0.8 → 12 bits) |
| `lowercase` / `stripPunctuation` / `stripNumbers` | Text normalization before comparing |
| `canonicalStrategy` | `longest` (default) or `first` |
| `maxDuplicatesListed` | Cap on the `duplicates` array per result (default 100) |
| `contentSelector` | CSS selector for the main content of fetched pages |
| `maxConcurrency` / `proxyConfiguration` | Fetching options |

### Output example

One item per input document:

```json
{
  "id": "product-a-copy",
  "url": null,
  "title": null,
  "wordCount": 56,
  "simhash": "738ba964da2a6e82",
  "clusterId": "c3",
  "clusterSize": 2,
  "isCanonical": false,
  "canonicalId": "product-a",
  "duplicateCount": 1,
  "duplicates": [
    { "id": "product-a", "url": null, "similarity": 0.9531, "jaccard": 0.8361, "simhashDistance": 3 }
  ],
  "clustersUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/CLUSTERS"
}
```

- `similarity` is the score used for matching: Jaccard (`minhash`), `1 - distance/64` (`simhash`), or the higher of the two (`both`).
- `jaccard` is the exact Jaccard similarity of the word-shingle sets; `simhashDistance` is the Hamming distance (0-64) between the two SimHashes.
- Fetch failures are returned as unbilled items with an `error` field.

The `CLUSTERS` record contains the settings, totals (documents, clusters, redundant documents, duplicate pairs), the LSH parameters used, and every multi-document cluster with its canonical document and duplicates.

### Pricing

This Actor uses **pay-per-event** pricing. You only pay for analyzed documents:

| Event | Price |
|---|---|
| Document analyzed (`document-analyzed`) | **$2 per 1,000 documents** ($0.002 each) |

That is about a third cheaper than comparable per-item deduplication tools (around $0.003 per item). Pages that fail to download or contain no text are **not charged**. Apify platform usage (compute) is billed separately: a 10,000-document run takes well under a minute on 1 GB. Set **Maximum cost per run** to cap your spend; the Actor only fetches and analyzes as many documents as the budget allows.

### FAQ

**What is the difference between MinHash and SimHash?**
MinHash estimates the **Jaccard similarity** of word shingles (overlapping k-word sequences). It is strict and precise, ideal for copied or scraped content. SimHash compresses each document into a 64-bit fingerprint whose **Hamming distance** reflects cosine similarity of its features. It is more tolerant of scattered word changes. `both` combines them: a pair matches if exact Jaccard reaches the threshold, **or** if SimHash similarity reaches it and the pair also shares at least half the threshold in Jaccard. That extra guard prevents random 64-bit collisions in large corpora.

**How many documents can it handle?**
Tested with 50,000 synthetic documents (about 600 words each): 53 s end to end, about 680 MB peak memory. Use `datasetId` for large corpora, since pasting 50k texts in the input is impractical. For more than about 100k documents, raise the memory.

**How accurate is it?**
On a 10,000-document synthetic benchmark, checked against brute-force exact comparison of all pairs among 3,000 documents: `minhash` found 100% of true pairs with 100% precision; `both` and `simhash` found 99.7% with 100% precision. Reported Jaccard scores are exact, not estimates.

**Which threshold should I use?**
0.8 (default) catches copies with small edits. Use 0.9+ for near-exact copies only, 0.6-0.7 for loosely rewritten content. For very short texts (titles, one-liners), lower `shingleSize` to 2-3.

**Which languages are supported?**
All languages that separate words with spaces (English, French, German, Spanish, Arabic, Russian…). Chinese/Japanese/Thai text without spaces is treated as long tokens, so detection is coarse there.

**Does it render JavaScript?**
No. Pages are fetched as HTML (fast and cheap). For JavaScript-heavy sites, crawl them first with a browser-based crawler and pass its dataset via `datasetId`.

**Is my data private?**
Texts are processed inside your Apify run and nothing is sent to third parties. Fetched pages are requested directly (or through your proxy settings).

**Is it legal to fetch the pages?**
The Actor only downloads publicly accessible pages you provide. Make sure you have the right to access and process the content, and respect the sites' terms of service.

# Actor input Schema

## `urls` (type: `array`):

Web pages to compare. The main content is extracted (navigation, header, footer, scripts, styles and asides are removed; <code>\<article></code> / <code>\<main></code> are preferred). Each page becomes one result.

## `texts` (type: `array`):

Raw texts to compare (with each other and with the URLs). Either plain strings or objects <code>{"id": "sku-1", "text": "..."}</code>. Each text becomes one result.

## `datasetId` (type: `string`):

Optional: compare the items of an existing dataset (e.g. the output of Website Content Crawler or any scraper). Best for large corpora (10k-50k+ documents) that are too big to paste as input. Set the field names below.

## `datasetTextField` (type: `string`):

Field holding the document text in each dataset item. Dotted paths are supported (e.g. <code>metadata.description</code>).

## `datasetIdField` (type: `string`):

Field used as the document ID and URL (e.g. <code>url</code>). Falls back to <code>dataset-\<index></code>.

## `method` (type: `string`):

<b>both</b> (recommended): MinHash LSH + SimHash candidates, a pair is a duplicate when exact Jaccard <i>or</i> SimHash similarity reaches the threshold. <b>minhash</b>: exact Jaccard on word shingles (strict, best for copied/scraped content). <b>simhash</b>: 64-bit SimHash Hamming similarity (tolerant to small word edits).

## `similarityThreshold` (type: `number`):

Minimum similarity (0-1) for two documents to be considered near-duplicates. 1 = exact duplicates only. MinHash uses Jaccard similarity of word shingles; SimHash uses 1 - HammingDistance/64.

## `shingleSize` (type: `integer`):

Number of consecutive words per shingle for MinHash/Jaccard. Smaller = more tolerant to edits, larger = stricter. 5 is a good default for web pages; use 2-3 for short texts like product titles.

## `numPermutations` (type: `integer`):

Number of MinHash hash functions. More = more accurate LSH candidate selection but slower. LSH bands and rows are chosen automatically for at least 99% recall at the threshold.

## `simhashMaxDistance` (type: `integer`):

Optional override: maximum Hamming distance (0-64) between 64-bit SimHashes for a pair to match. Leave empty to derive it from the similarity threshold (0.8 → 12 bits).

## `lowercase` (type: `boolean`):

Ignore letter case when comparing.

## `stripPunctuation` (type: `boolean`):

Ignore punctuation and symbols when comparing.

## `stripNumbers` (type: `boolean`):

Ignore numbers (prices, dates, counters) when comparing. Useful for listings that only differ by price or date.

## `canonicalStrategy` (type: `string`):

Which document of a cluster is flagged <code>isCanonical</code>: the <b>longest</b> (most complete; ties go to the first) or the <b>first</b> in input order.

## `maxDuplicatesListed` (type: `integer`):

Caps the <code>duplicates</code> array of each result (the most similar are kept). <code>duplicateCount</code> is always the full count.

## `contentSelector` (type: `string`):

Optional CSS selector for the main content of fetched pages (e.g. <code>.post-body</code>). Default: <code>article</code>, then <code>main</code>, then the cleaned <code>body</code>.

## `maxConcurrency` (type: `integer`):

Maximum number of pages fetched in parallel.

## `proxyConfiguration` (type: `object`):

Optional proxy for fetching URLs (e.g. Apify Proxy for sites that block datacenter IPs).

## Actor input object example

```json
{
  "urls": [
    "https://example.com",
    "https://example.org"
  ],
  "texts": [
    "First document text...",
    {
      "id": "doc-2",
      "text": "Second document text..."
    }
  ],
  "datasetTextField": "text",
  "datasetIdField": "url",
  "method": "both",
  "similarityThreshold": 0.8,
  "shingleSize": 5,
  "numPermutations": 128,
  "lowercase": true,
  "stripPunctuation": true,
  "stripNumbers": false,
  "canonicalStrategy": "longest",
  "maxDuplicatesListed": 100,
  "maxConcurrency": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `documents` (type: `string`):

No description

## `clusters` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://example.com",
        "https://example.org",
        "https://example.net",
        "https://www.iana.org/help/example-domains"
    ],
    "texts": [
        {
            "id": "product-a",
            "text": "Our stainless steel water bottle keeps drinks cold for 24 hours and hot for 12 hours. The double-wall vacuum insulation prevents condensation, the leak-proof lid fits in any backpack, and the powder-coated finish resists scratches. Dishwasher safe and free of BPA. Available in five colors and three sizes for the gym, the office or your next hike."
        },
        {
            "id": "product-a-copy",
            "text": "Our stainless-steel water bottle keeps drinks cold for 24 hours and hot for 12 hours! The double-wall vacuum insulation prevents condensation, the leak-proof lid fits in any bag, and the powder-coated finish resists scratches. Dishwasher safe and free of BPA. Available in five colors and three sizes for the gym, the office or your next hike."
        },
        {
            "id": "product-b",
            "text": "This ergonomic office chair features adjustable lumbar support, breathable mesh, 4D armrests and a synchronized tilt mechanism. The aluminium base and silent casters make it ideal for long working days at home or in the office. Assembly takes about ten minutes and the chair comes with a five-year warranty."
        }
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("freecamp008/near-duplicate-finder").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urls": [
        "https://example.com",
        "https://example.org",
        "https://example.net",
        "https://www.iana.org/help/example-domains",
    ],
    "texts": [
        {
            "id": "product-a",
            "text": "Our stainless steel water bottle keeps drinks cold for 24 hours and hot for 12 hours. The double-wall vacuum insulation prevents condensation, the leak-proof lid fits in any backpack, and the powder-coated finish resists scratches. Dishwasher safe and free of BPA. Available in five colors and three sizes for the gym, the office or your next hike.",
        },
        {
            "id": "product-a-copy",
            "text": "Our stainless-steel water bottle keeps drinks cold for 24 hours and hot for 12 hours! The double-wall vacuum insulation prevents condensation, the leak-proof lid fits in any bag, and the powder-coated finish resists scratches. Dishwasher safe and free of BPA. Available in five colors and three sizes for the gym, the office or your next hike.",
        },
        {
            "id": "product-b",
            "text": "This ergonomic office chair features adjustable lumbar support, breathable mesh, 4D armrests and a synchronized tilt mechanism. The aluminium base and silent casters make it ideal for long working days at home or in the office. Assembly takes about ten minutes and the chair comes with a five-year warranty.",
        },
    ],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("freecamp008/near-duplicate-finder").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://example.com",
    "https://example.org",
    "https://example.net",
    "https://www.iana.org/help/example-domains"
  ],
  "texts": [
    {
      "id": "product-a",
      "text": "Our stainless steel water bottle keeps drinks cold for 24 hours and hot for 12 hours. The double-wall vacuum insulation prevents condensation, the leak-proof lid fits in any backpack, and the powder-coated finish resists scratches. Dishwasher safe and free of BPA. Available in five colors and three sizes for the gym, the office or your next hike."
    },
    {
      "id": "product-a-copy",
      "text": "Our stainless-steel water bottle keeps drinks cold for 24 hours and hot for 12 hours! The double-wall vacuum insulation prevents condensation, the leak-proof lid fits in any bag, and the powder-coated finish resists scratches. Dishwasher safe and free of BPA. Available in five colors and three sizes for the gym, the office or your next hike."
    },
    {
      "id": "product-b",
      "text": "This ergonomic office chair features adjustable lumbar support, breathable mesh, 4D armrests and a synchronized tilt mechanism. The aluminium base and silent casters make it ideal for long working days at home or in the office. Assembly takes about ten minutes and the chair comes with a five-year warranty."
    }
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call freecamp008/near-duplicate-finder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,freecamp008/near-duplicate-finder"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/KtCgBchcL5YpphPum/builds/JkkQYc9436NcDWUvg/openapi.json
