# Remove Duplicates from Datasets, CSV & JSON - Smart Dedupe (`admirala/smart-dedupe`) Actor

Deduplicate Apify datasets, CSV or JSON files: match on chosen fields, normalize URLs, emails and whitespace, keep first or last, merge several datasets in one run. $0.0009 per input item.

- **URL**: https://apify.com/admirala/smart-dedupe.md
- **Developed by:** [Ja doei](https://apify.com/admirala) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.60 / 1,000 per input item deduplicateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Remove Duplicates from Datasets, CSV & JSON - Smart Dedupe

> ✅ **Tested daily** with its default input (Apify's automated QA plus our own smoke test before every release).

**Remove duplicates** from Apify datasets, CSV files or JSON files: merge one or more sources and keep only unique rows, matched on the fields you choose with URL, email and whitespace normalization. **$0.0009 per input item**, no start fee.

### What it does

- **Match on the fields you choose** (for example `url`, `email`, `name`), or on the whole item.
- **Normalizes before comparing** (optional, on by default): trims and lowercases text, strips `http(s)://`, `www.`, trailing slashes and tracking parameters (`utm_*`, `fbclid`, `gclid`). So `https://www.example.com/a/?utm_source=x` and `example.com/a` count as the same.
- **Keep the first or the last** occurrence of each duplicate.
- **Merges several sources in one run**: dataset IDs, CSV/JSON URLs and inline items together.

### Output

- Unique items in the default dataset, in their original order.
- A summary in the key-value store record `OUTPUT`: input items, unique items, duplicates removed.

### Pricing

Pay per event: **per input item**. Lower prices on Silver and Gold plans. No start fee. Platform usage is included.

### Input example

```json
{
  "datasetIds": ["YOUR_DATASET_ID"],
  "fields": ["url"],
  "normalize": true,
  "keep": "first"
}
```

### Notes

- Works only on data you provide (your datasets or files). It does not collect any data itself.
- Large datasets are streamed from the Apify API; output is written in batches of 1,000.

### Use with AI agents (MCP)

This Actor can be used as a tool by AI agents (Claude, Cursor, VS Code, other MCP clients) through the official [Apify MCP server](https://docs.apify.com/platform/integrations/mcp):

- Add only this Actor as a tool: `https://mcp.apify.com?tools=admirala/smart-dedupe` (sign in with OAuth or an Apify API token).
- Or connect `https://mcp.apify.com` and let the agent find it with `search-actors` (e.g. "remove duplicates"), read the input schema with `fetch-actor-details` and run it with `call-actor`.

Example input an agent can pass:

```json
{
  "datasetIds": [
    "YOUR_DATASET_ID"
  ],
  "fields": [
    "url"
  ],
  "normalize": true,
  "keep": "first"
}
```

Cost per call: $0.0009 per input item (lower on higher Apify plans). Results come back as dataset items (`get-dataset-items`).

### FAQ

**How do I remove duplicate rows from an Apify dataset?**
Put the dataset ID in `datasetIds` and the field(s) to compare in `fields`, e.g. `["url"]`.

**Can I deduplicate a CSV file?**
Yes, give a direct CSV or JSON file URL in `urls`.

**Are `https://www.example.com/a/` and `example.com/a` duplicates?**
Yes with `normalize: true` (default): scheme, www, trailing slash and utm parameters are ignored.

# Actor input Schema

## `datasetIds` (type: `array`):

Apify dataset IDs to merge and deduplicate, e.g. \["aBcD1234EfGh"]. Items from all sources are combined.

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

Direct links to CSV or JSON files (array of objects) to include, e.g. \["https://example.com/leads.csv"].

## `items` (type: `array`):

Optional inline items (array of objects) to include, e.g. \[{"url": "https://example.com/a"}].

## `fields` (type: `array`):

Fields that define a duplicate, e.g. \["url"] or \["name", "email"]. Empty = compare the whole item.

## `normalize` (type: `boolean`):

true = trim and lowercase, strip http(s)://, www., trailing slash and tracking parameters (utm\_\*, fbclid, gclid) before comparing.

## `keep` (type: `string`):

Which occurrence of each duplicate to keep: 'first' or 'last'.

## Actor input object example

```json
{
  "items": [
    {
      "url": "https://example.com/a?utm_source=x"
    },
    {
      "url": "https://www.example.com/a/"
    },
    {
      "url": "https://example.com/b"
    }
  ],
  "fields": [
    "url"
  ],
  "normalize": true,
  "keep": "first"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (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 = {
    "items": [
        {
            "url": "https://example.com/a?utm_source=x"
        },
        {
            "url": "https://www.example.com/a/"
        },
        {
            "url": "https://example.com/b"
        }
    ],
    "fields": [
        "url"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("admirala/smart-dedupe").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 = {
    "items": [
        { "url": "https://example.com/a?utm_source=x" },
        { "url": "https://www.example.com/a/" },
        { "url": "https://example.com/b" },
    ],
    "fields": ["url"],
}

# Run the Actor and wait for it to finish
run = client.actor("admirala/smart-dedupe").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 '{
  "items": [
    {
      "url": "https://example.com/a?utm_source=x"
    },
    {
      "url": "https://www.example.com/a/"
    },
    {
      "url": "https://example.com/b"
    }
  ],
  "fields": [
    "url"
  ]
}' |
apify call admirala/smart-dedupe --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,admirala/smart-dedupe"
        }
    }
}
```

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/mdZpGSvioUOTbfeAN/builds/as3jwKQGRlybYTx2T/openapi.json
