# Merge & Dedup Datasets - Only New Items, Filter, Transform (`radarweb/dataset-merge-dedup`) Actor

Merge any number of datasets into one clean list: remove duplicates by any field (smart URL matching), return only items that are new since the last run, filter rows and pick/rename columns. Streams millions of rows.

- **URL**: https://apify.com/radarweb/dataset-merge-dedup.md
- **Developed by:** [Riccardo Bonadio](https://apify.com/radarweb) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 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.

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

## Merge & Dedup Datasets: only new items, filter, transform

**Combine the results of many scraper runs into one clean list.** Paste the dataset IDs, choose which field identifies a duplicate (for example `url`, `email` or `placeId`), and get back a single deduplicated, filtered dataset, ready for export to CSV, Excel or JSON.

### What it is for

- You ran the same scraper 20 times (different cities, keywords, days) and need **one master list without duplicates**.
- You want to **filter** the rows (only `rating ≥ 4`, only `country = IT`, only rows where `email` exists).
- You want to **clean the columns**: keep only some fields, drop others, rename them before sending to a CRM.

### Only new items since the last run

Turn on **Only new items** and the Actor remembers every item it has already delivered (by your key fields, e.g. `url`). Schedule a scraper + this Actor and each run gives you **just what is new**: new listings, new jobs, new reviews. The memory is kept in your account under a name you choose, so you can have one per project. Only rows actually delivered are remembered: if a run is cut short (max items or cost limit), the rest comes in the next run, so nothing is ever lost.

### Why this one

| | This Actor |
|---|---|
| Smart URL matching | `https://www.site.com/a/`, `http://site.com/a#top` and `site.com/a?utm_source=x` are recognised as the **same** URL; real parameters like `?id=5` are kept |
| Case- and space-insensitive | `ACME Inc` = `acme  inc` (can be switched off) |
| Multi-field and nested keys | e.g. `name` + `address.city` |
| Items with an empty key are kept | rows without an email are not all collapsed into one |
| Streams data | low memory, handles millions of rows; only a short hash of each key is kept in memory (about 120 bytes per unique item) |
| Clear errors | a wrong dataset ID is reported and skipped, never silently created |
| Fair pricing | you pay only for rows written to the output. **Removed duplicates and filtered rows are free.** |

### Input example

```json
{
  "datasetIds": ["aBcD123...", "eFgH456..."],
  "dedupFields": ["url"],
  "filters": [{ "field": "rating", "operator": "gte", "value": 4 }],
  "fields": ["title", "url", "rating", "phone"],
  "renameFields": { "title": "name" },
  "addSourceField": "_source"
}
```

Filter operators: `eq`, `ne`, `contains`, `notContains`, `exists`, `notExists`, `gt`, `gte`, `lt`, `lte`, `regex`, `in`.
Filters run first, then deduplication (on the original field names), then field selection/renaming.

### Output

One row per unique item. A `SUMMARY` record in the key-value store reports items read, written, duplicates removed and any datasets that could not be found.

### Use it in a pipeline

Call it from another Actor, from an integration ("run after the scraper finishes") or via API, and set **Output dataset name** to keep appending runs into one named master dataset.

### Pricing

Pay per output item (see the Pricing tab). With a maximum cost per run set in the run options, the Actor stops cleanly when the limit is reached.

# Actor input Schema

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

IDs or names of the datasets to read, in order. Paste the dataset ID from any previous run (Storage → Datasets). Pick a dataset (ID or name). Leave empty to try it with built-in sample data.

## `deduplicate` (type: `boolean`):

Keep only the first occurrence of each item.

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

Fields that identify a duplicate, e.g. url or email. Supports nested paths like address.city. Leave empty to compare whole items.

## `onlyNewSinceLastRun` (type: `boolean`):

Skip items already delivered in earlier runs of this Actor with the same memory name. Perfect for scheduled monitoring: each run returns only what is new.

## `stateKey` (type: `string`):

Use a different name per project (e.g. 'rome-restaurants'). Stored in the key-value store 'dedup-memory' in your account; delete it to start fresh.

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

Treat http/https, www., trailing slashes and utm\_/gclid/fbclid parameters as the same URL.

## `caseSensitive` (type: `boolean`):

By default 'ACME Inc' and 'acme inc' are duplicates. Turn on to treat them as different.

## `filters` (type: `array`):

Keep only rows matching these conditions. Each: {"field": "price", "operator": "lt", "value": 100}. Operators: eq, ne, contains, notContains, exists, notExists, gt, gte, lt, lte, regex, in.

## `filterMode` (type: `string`):

'all' = every condition must match (AND). 'any' = at least one (OR).

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

Leave empty to keep all fields.

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

Fields to drop from the output.

## `renameFields` (type: `object`):

Map of old name → new name, e.g. {"title": "name"}.

## `addSourceField` (type: `string`):

If set (e.g. \_source), each row gets a column with the dataset it came from.

## `maxItems` (type: `integer`):

Stop after writing this many items. 0 = no limit.

## `outputDatasetName` (type: `string`):

Write to a named dataset instead of the run's default dataset — handy for building one master list across many runs.

## Actor input object example

```json
{
  "deduplicate": true,
  "dedupFields": [
    "url"
  ],
  "onlyNewSinceLastRun": false,
  "stateKey": "default",
  "normalizeUrls": true,
  "caseSensitive": false,
  "filters": [],
  "filterMode": "all",
  "fields": [],
  "omitFields": [],
  "renameFields": {},
  "maxItems": 0
}
```

# 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 = {
    "dedupFields": [
        "url"
    ]
};

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

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

```

## MCP server setup

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

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/1HxMNm7eUVjQBUd25/builds/qptmU36GwzufK0qu0/openapi.json
