# Dataset Merge & Dedup (`ucchiii/dataset-dedup-merge`) Actor

Merge any number of Apify datasets into one and remove duplicates by the fields you choose (e.g. url, placeId, email). Case/whitespace/URL normalization, keep first or last, pick or omit fields. $0.50 per 1,000 output items.

- **URL**: https://apify.com/ucchiii/dataset-dedup-merge.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 1,000 output items

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

## Dataset Merge & Dedup — combine Apify datasets, remove duplicates

**For anyone who runs Apify scrapers more than once and ends up with overlapping results.** This Actor **merges any
number of Apify datasets into one clean dataset and removes duplicates** by the fields you choose.
**$0.50 per 1,000 output items**; reading and comparing is free.

- **Dedup by any fields**: `url`, `placeId`, `title + company`, nested fields like `address.city`, or whole items
- **Smart matching**: ignore letter case, extra whitespace, full-width characters; optional URL normalization (http/https, www, trailing slash)
- **Keep first or last** (e.g. "newest run wins")
- **Output unique items or only the duplicates** (to audit what was removed)
- **Pick / omit fields**, optionally tag each item with its source dataset
- Items are processed as a stream (never all loaded at once), but the dedup keys of everything seen so far are kept in memory — comfortable up to a few million items; for larger datasets split the run (keep="last" also holds one position per key)
- **$0.50 per 1,000 output items.** Reading and comparing is free; you pay only for what is written.

### Input example

```json
{
  "datasetIds": ["aBcDeF123", "gHiJkL456"],
  "dedupFields": ["placeId"],
  "keep": "last",
  "normalizeUrls": true
}
```

### Output

The merged items in the default dataset. Run statistics are saved in the key-value store as `STATS`:

```json
{ "datasets": 2, "itemsRead": 15234, "duplicatesFound": 4120, "itemsWritten": 11114, "stoppedAtChargeLimit": false }
```

### Use cases

- Combine Google Maps / jobs / e-commerce scraper runs and remove repeated places, jobs or products
- Merge daily runs into one master list keeping the latest version of each record
- Find which records appear in more than one dataset (`output: duplicatesOnly`)

### Pricing

Pay per event: **$0.0005 per output item** ($0.50 per 1,000). Set a max charge per run to cap spend.

### More tools from the same developer

- [Google Sheets Export](https://apify.com/ucchiii/google-sheets-export) — export an Apify dataset to Google Sheets
- [Google Maps Leads Cleaner](https://apify.com/ucchiii/maps-leads-cleaner) — dedupe Google Maps scraper results, format phones (E.164), CRM-ready leads
- [Job Postings Normalizer](https://apify.com/ucchiii/job-postings-normalizer) — unify fields, salaries and dates from any job scraper and remove duplicates
- [SERP Analyzer](https://apify.com/ucchiii/serp-dataset-analyzer) — rankings, share of voice and People Also Ask from Google Search scraper datasets
- [Japanese Text Toolkit](https://apify.com/ucchiii/japanese-text-toolkit) — furigana, romaji, wareki dates and normalization for Japanese text

# Actor input Schema

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

Dataset IDs (the 'defaultDatasetId' of a finished run of the source Actor, e.g. 'WkzbQMuFYuamGv3YF'). Dataset IDs or names to merge, in order. Items are read in this order (this matters for 'keep first/last'). Leave empty to run a free demo on sample data (not charged). You can also paste the dataset URL from Apify Console or the API (the ID is taken from it).

## `dedupFields` (type: `array`):

Items with the same values in ALL these fields are duplicates. Use dots for nested fields (e.g. \['url'] or \['address.city']). Empty = compare whole items.

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

When duplicates are found, keep the 'first' or the 'last' occurrence (datasets are read in the order given). Default: first.

## `output` (type: `string`):

'unique' returns the deduplicated items (default). 'duplicatesOnly' returns only the duplicates that were removed (for auditing).

## `caseInsensitive` (type: `boolean`):

Treat 'Acme' and 'acme' as the same value.

## `trimWhitespace` (type: `boolean`):

Treat ' Acme  Inc ' and 'Acme Inc' as the same value.

## `normalizeUrls` (type: `boolean`):

Treat http/https, www and a trailing slash as the same URL.

## `dedupEmptyKeys` (type: `boolean`):

By default, items whose dedup fields are all empty are kept (never treated as duplicates).

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

Top-level fields to output. Empty = all fields.

## `omitFields` (type: `array`):

Top-level fields to remove from the output.

## `addSourceField` (type: `boolean`):

Adds '\_sourceDatasetId' to each output item.

## Actor input object example

```json
{
  "keep": "first",
  "output": "unique",
  "caseInsensitive": true,
  "trimWhitespace": true,
  "normalizeUrls": false,
  "dedupEmptyKeys": false,
  "addSourceField": false
}
```

# Actor output Schema

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

The merged, deduplicated items with their original fields (or only the removed duplicates if output is 'duplicatesOnly').

## `stats` (type: `string`):

Record STATS: run counts (items read, kept, duplicates removed).

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/dataset-dedup-merge").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/dataset-dedup-merge").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 '{}' |
apify call ucchiii/dataset-dedup-merge --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/dataset-dedup-merge"
        }
    }
}
```

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/TB0061t5mwLM0Ibfu/builds/AiLZAbxmE9uSTh4wH/openapi.json
