# Merge and deduplicate scraped datasets

**Use case:** 

Merge several Apify datasets or runs into one and remove duplicate rows by the key fields you choose (for example url or id), keeping the first or last copy. This example runs on built-in synthetic demo rows; select your own source datasets to clean real scrape results before export.

## Input

```json
{
  "runIds": [],
  "keyFields": [
    "id"
  ],
  "keep": "first",
  "caseInsensitive": false,
  "trim": true,
  "ignoreEmpty": true,
  "onlyDuplicates": false,
  "pickFields": [],
  "omitFields": [],
  "batchSize": 1000,
  "maxItems": 50,
  "demoMode": true
}
```

## Output

```json
{
  "item": {
    "label": "item",
    "format": "object"
  },
  "occurrences": {
    "label": "occurrences",
    "format": "integer"
  },
  "sourceDatasetId": {
    "label": "sourceDatasetId",
    "format": "string"
  },
  "sourceIndex": {
    "label": "sourceIndex",
    "format": "integer"
  }
}
```

## How it works

### 1. Sign up on Apify or log in

The Dataset Deduplication & Merge - Remove Duplicates JSON Actor is ready to run with the inputs already set for "Merge and deduplicate scraped datasets". [Sign up or log in](https://console.apify.com/create-task-from-example/MwUyfKOx2tjDwwkSB) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "Merge and deduplicate scraped datasets" task

The Dataset Deduplication & Merge - Remove Duplicates JSON Actor will start running based on the input automatically. You can also change all the input fields, like source run ids (advanced), deduplication key fields, and more, to match your specific use case.

### 3. Receive the "Merge and deduplicate scraped datasets" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as item, occurrences, sourcedatasetid, and more.

### 4. Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also [run the "Merge and deduplicate scraped datasets" task via API](https://apify.com/ahmed.fouaad82/dataset-dedup-merge.md).

## FAQ

### What does the merge and deduplicate task do?

The merge and deduplicate task reads the selected datasets or runs, keeps one row per unique key (for example url or id) and writes the merged result to a new dataset.

### Does the merge and deduplicate task example use real data?

No. The merge and deduplicate task example uses four built-in synthetic product rows with one duplicate. Select your own datasets to process real data.

### How much does the merge and deduplicate task cost?

The first 50 source rows of every run of the merge and deduplicate task are free. After that the Actor charges per saved source row; the Pricing tab shows the current price.

## About this Actor

This example demonstrates how to use [Dataset Deduplication & Merge - Remove Duplicates JSON](https://apify.com/ahmed.fouaad82/dataset-dedup-merge.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/ahmed.fouaad82/dataset-dedup-merge.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

This Task's input is already configured above. Use it as-is rather than inventing a new one.

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 full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/ahmed.fouaad82/dataset-dedup-merge.md

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`).
