# Merge & Dedup Datasets – Keep Only New Items (`justaduck/dedup-datasets-new-items`) Actor

Merge several Apify datasets into one and remove duplicates by any fields (url, id, name + city) or by full content. Optionally keep only items not seen in earlier runs, for scheduled scrapers and integrations. Keeps every field. Limited permissions. Pay only for items returned.

- **URL**: https://apify.com/justaduck/dedup-datasets-new-items.md
- **Developed by:** [Justaduck](https://apify.com/justaduck) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 1,000 unique 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/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 – Keep Only New Items

**Merge and dedup datasets: combine several Apify datasets into one, remove duplicates by the fields you choose, and optionally keep only the items you have not seen in earlier runs.**

- **What you get:** one dataset with every unique item from your input datasets, with the same fields they had (the first copy of each duplicate is kept, in dataset order). The run summary says, per dataset, how many items were read, returned, removed as duplicates and skipped as already seen.
- **What it costs:** US$0.50 per 1,000 items returned plus US$0.0005 per run start. Duplicates, items skipped as already seen and demo data are not charged. Apify's free plan (US$5 of usage a month) covers about 10,000 items. That is the price on Apify's Free plan; on paid Apify plans it goes down to US$0.35 per 1,000 items returned, the "from" price on the Store page.
- **Try it:** You can see example output in the **Output** section below without running anything. To try it yourself, click **Start** with **Datasets** left empty: it merges two small demo datasets (5 job postings each) by `url` and returns 7 unique items in a few seconds. Demo items are marked `isDemoData: true` and are not charged (only the standard US$0.0005 run start).

Use it after any scraper: pick the datasets of several runs (or let an integration pass the dataset of the run that just finished), choose the dedup fields such as `url` or `id`, and get one clean list. Turn on **Only items not seen in earlier runs** to get just the new items every time a scheduled scraper runs: the Actor remembers which items it already returned, in your own account.

**Only use datasets you have the right to process.** This Actor runs with Apify's limited permissions: it can read only the datasets you select in its input, and it writes only to its own run storage and its memory store in your account.

### What you can use it for

- **Only new results from a scheduled scraper:** run a job board, tender or listing scraper every day and pass each run's dataset here with **Only items not seen in earlier runs** on; you get only the postings that were not in any earlier run.
- **Merge several runs into one list:** combine the results of different searches, countries or keywords, removing items that several searches found.
- **Clean a dataset:** remove exact duplicate rows, or rows with the same `url`, `id`, e-mail hash or `name` + `city`.

### How to use it

1. Open [this Actor on Apify Store](https://apify.com/justaduck/dedup-datasets-new-items) and try it in Apify Console. A free Apify account is enough; no credit card is needed.
2. You can see example output in the **Output** section below without running anything. To try it, leave **Datasets** empty and click **Start**: the run merges two demo datasets and returns 7 unique items in a few seconds, marked `isDemoData: true` and not charged.
3. In **Datasets**, pick your own datasets (in the order you want them merged). In **Dedup fields**, list the field(s) that identify the same item, such as `url`. Leave it empty to remove only items that are identical in every field.
4. For scheduled runs, turn on **Only items not seen in earlier runs** and give a **Memory name**, for example `jobs-weekly`. Use one name per pipeline.
5. Open the **Output** tab when the run finishes and export the items as JSON, CSV or Excel, or connect the next step with Apify **integrations** (Make, Zapier, n8n, Slack, Google Sheets, webhooks) or the **Apify API**.

#### Get only new items after any Actor (integration)

To run this automatically after another Actor (for example a scraper you run on a schedule):

1. Open the scraper's saved task (or the Actor) → **Integrations** → **Connect Actor or task** → choose this Actor, triggered when the run **succeeds**.
2. Set the input of this Actor to:

```json
{
    "datasetIds": ["{{resource.defaultDatasetId}}"],
    "dedupFields": ["url"],
    "onlyNewItems": true,
    "memoryName": "my-scraper-new-items"
}
```

`{{resource.defaultDatasetId}}` is replaced by the dataset of the run that just finished. Each time the scraper runs, this Actor returns only the items whose `url` was not returned before, and you can send them on with a second integration (e-mail, Slack, Google Sheets). The same input works with a **webhook** that calls this Actor through the API, or with two **schedules** a few minutes apart (the second one using a fixed dataset name instead of `{{resource.defaultDatasetId}}`).

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `datasetIds` | array | empty = demo run (not charged) | The datasets to merge, in order. Pick them in the form, or give dataset IDs or `username~dataset-name` (in the API, CLI or an integration too). With limited permissions only the datasets given here can be read; Apify grants access to them by ID or name, so prefer those over Console or API URLs. Up to 100 per run; the same dataset given twice is read once. |
| `dedupFields` | array of strings | `[]` | Fields that identify a duplicate. Several fields are combined (all must match). Nested fields use dots: `company.id`. Values must match exactly, including type (the number `1` and the text `"1"` are different) and letter case. Items where all these fields are empty are compared by their whole content instead. Empty list = compare whole items. |
| `onlyNewItems` | boolean | `false` | Return only items whose dedup key was not returned in an earlier run with the same memory. |
| `memoryName` | string | — | Required with `onlyNewItems`. Letters, numbers, spaces, `.`, `_`, `-`. Same name + same dedup fields = same memory. |
| `forgetAfterDays` | integer | `90` | Items not seen in any run for this many days are removed from the memory (7–3,650). |
| `maxItems` | integer | no limit | Maximum number of items to return. Items after the limit are not returned, not charged and not remembered. |

### Output

The demo run (Datasets left empty) returns items like these (two of the 7 shown). You don't need to run it to see this. Demo items carry `isDemoData: true`; the Actor never adds this field to items from your own datasets.

```json
{
    "url": "https://www.example.com/jobs/101",
    "title": "Data Analyst",
    "city": "Austin",
    "postedDate": "2026-11-21",
    "sourceUrl": "https://api.apify.com/v2/datasets/knjG69HLEYFoQcTTT/items?format=json&offset=0&limit=1",
    "isDemoData": true
}
```

```json
{
    "url": "https://www.example.com/jobs/106",
    "title": "Data Engineer",
    "city": "Chicago",
    "postedDate": "2026-11-26",
    "sourceUrl": "https://api.apify.com/v2/datasets/XYhmJmrqYKJ1f4HSD/items?format=json&offset=2&limit=1",
    "isDemoData": true
}
```

#### Fields

| Field | Type | Description |
|---|---|---|
| (your fields) | any | Every field of the item as it was in your dataset, in the same order. |
| `sourceUrl` | string | Kept as it is when the item already has an absolute URL in `sourceUrl` (most scrapers do). Otherwise it is set to a link to that exact item in the Apify API (dataset, position). |
| `originalSourceUrl` | any | Only when the item had a `sourceUrl` value that is not an absolute URL: that original value, so nothing is overwritten. |
| `isDemoData` | boolean | Only on demo items (the run with **Datasets** left empty): `true`. Demo items are not charged. |

**The output is exactly the data you put in, unchanged:** every value is returned as it is in your datasets (no masking, no rewriting); only duplicates are removed and `sourceUrl` is added where it was missing.

### Pricing

Pay per event: **US$0.0005 per run start + US$0.50 per 1,000 items returned** (US$0.0005 per item).

| Run | Items read | Items returned | Cost |
|---|---|---|---|
| Demo run (Datasets empty) | 10 | 7 | US$0.0005 (run start only; demo items are not charged) |
| Daily new items from a 2,000-item scraper (50 new a day) | 2,000 | 50 | US$0.025 + US$0.0005 |
| Merge 5 runs of 6,000 items, 30% overlap | 30,000 | 21,000 | US$10.50 + US$0.0005 |

Discounts by Apify plan (per 1,000 items): Free $0.50, Bronze $0.45, Silver $0.40, Gold $0.35.

**Free plan:** Apify's free plan includes US$5 of prepaid usage every month (no credit card needed), enough for about 10,000 returned items a month.

**Not charged:** items removed as duplicates, items skipped as seen in earlier runs, datasets that cannot be read, and demo data (the run with Datasets left empty). Use **Max items** or Apify's "maximum cost per run" to cap a run.

### Limits and behaviour

- **Speed:** each returned item is saved and charged on its own, which sets the pace on the Apify platform: roughly 10–15 items per second. Reading and comparing is much faster, so a daily "new items only" run over a large dataset that returns few new items finishes quickly. A run lasts at most about 55 minutes; datasets not reached are listed as `not-run`.
- **Memory (RAM):** the keys of all items read in one run are kept in memory. 256 MB is enough for about a million short keys; raise the memory for larger merges.
- **Order:** datasets are read in the order given, items in dataset order; the first copy of a duplicate is the one returned.
- **Items must be JSON objects.** A dataset with other values (plain strings, arrays) is skipped with a reason.
- **Hidden fields** (names starting with `#`) and empty items are not read (`clean` mode of the dataset API).
- **Memory store:** the "only new" memory is saved in your account in the key-value store `dedup-datasets-new-items-state` after each dataset, on platform migration and at the end of the run. Two runs that use the same memory at the same time are not allowed: the second one stops before returning anything. If the memory is damaged, the run stops before returning anything and tells you which records to delete.
- If a run is aborted, items already returned are remembered; the item being written at that moment may be returned again next time.

### Use with AI agents (MCP)

AI agents can run this Actor through the [Apify MCP server](https://docs.apify.com/mcp) (Model Context Protocol). There are two ways to connect:

- **Load this Actor as its own tool:** add `https://mcp.apify.com?tools=justaduck/dedup-datasets-new-items` to your MCP client. The server exposes it as the tool `justaduck--dedup-datasets-new-items`.
- **Let the agent find it:** connect to `https://mcp.apify.com` (default tools). The agent can find this Actor with `search-actors`, read its input schema with `fetch-actor-details` and start it with `call-actor`.

On first connection you sign in to Apify with OAuth (or send your Apify API token as a Bearer header). The agent passes the same fields as in the Input section. A run returns its dataset ID, and the agent reads the rows with `get-dataset-items`. Runs started this way run on your Apify account and are charged as in the Pricing section; `call-actor` also accepts `maxTotalChargeUsd` in `callOptions` to cap what one run can spend.

### FAQ

**How do I remove duplicates from an Apify dataset?**
Pick the dataset in **Datasets**, put the field that identifies an item (for example `url`) in **Dedup fields** and click **Start**. The output is the same dataset without duplicates.

**How do I get only new items from a scheduled scraper?**
Turn on **Only items not seen in earlier runs**, give a **Memory name**, and connect this Actor to your scraper's task with an integration using `{{resource.defaultDatasetId}}` (see "Get only new items after any Actor"). Each run returns only items not returned before.

**How do I merge datasets from several Actor runs?**
Select all the datasets in **Datasets**. They are read in order and merged into one output dataset; duplicates across them are removed.

**Why does it say "No permission to read this dataset"?**
With limited permissions this Actor can read only the datasets given in its input. Select the dataset in the **Datasets** field, or pass its dataset ID (or `username~dataset-name`) there in the API, CLI or integration input. Use the ID rather than a Console or API URL, and check that the dataset is in your account or shared with you.

**Can I dedup by two fields together?**
Yes. List both, for example `name` and `city`: two items are duplicates only when both values match.

**What happens if I change the dedup fields?**
The memory is kept per memory name and dedup fields, so new dedup fields start a fresh memory: the first run returns all items again.

**Is this an official Apify tool?**
No. It is built by an independent developer on the Apify platform and uses the public Apify API to read the datasets you select.

### Related Actors

Actors by the same author whose daily results work well with "only new items":

- **[Greenhouse Jobs Scraper – Lever & Ashby ATS Jobs](https://apify.com/justaduck/greenhouse-lever-ashby-jobs)**: every open job on company career pages; dedup by `sourceUrl` to get only new jobs.
- **[SAM.gov Federal Contracts & Bid Opportunities](https://apify.com/justaduck/sam-gov-contract-opportunities)**: US federal contract opportunities; dedup by `noticeId` to get only new notices.
- **[TED Tenders Scraper – EU Public Procurement](https://apify.com/justaduck/eu-ted-tenders)**: EU tenders; dedup by `publicationNumber`.
- **[UK Tenders – Find a Tender & Contracts Finder](https://apify.com/justaduck/uk-government-tenders)**: UK public tenders; dedup by `ocid` and `releaseId` to get each new notice release.
- **[PDF to Text Extractor – Page Text & Metadata](https://apify.com/justaduck/pdf-to-text-extractor)**: turn the PDF links in your results into text.

# Actor input Schema

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

The datasets to merge, in this order. Pick them from your account, or give dataset IDs or username~dataset-name (for example the defaultDatasetId of another Actor's run, {{resource.defaultDatasetId}} in an integration). With limited permissions this Actor can read only the datasets listed here, by ID or name. Leave it empty to try the Actor on two small demo datasets (demo items are not charged).

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

Field names that identify a duplicate, for example url, or name and city together. Nested fields use dots (address.city). Values must match exactly (same text and type). Leave empty to remove only items that are identical in every field.

## `onlyNewItems` (type: `boolean`):

Remember the dedup keys of every item this Actor returns, and in later runs return only items whose key was not returned before. The memory is stored in your own account (key-value store dedup-datasets-new-items-state) under the Memory name below.

## `memoryName` (type: `string`):

Required when "Only items not seen in earlier runs" is on. Use one name per pipeline, for example jobs-weekly; runs with the same name and the same dedup fields share one memory, other names have their own. Changing the dedup fields starts a fresh memory.

## `forgetAfterDays` (type: `integer`):

Items that have not appeared in any run for this many days are dropped from the memory, so they count as new if they come back. Every run where an item appears again (returned or skipped) resets its clock.

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

Maximum number of items to return after removing duplicates. Leave empty for no limit. You pay only for items returned.

## Actor input object example

```json
{
  "datasetIds": [
    "knjG69HLEYFoQcTTT",
    "XYhmJmrqYKJ1f4HSD"
  ],
  "dedupFields": [
    "url"
  ],
  "onlyNewItems": false,
  "forgetAfterDays": 90
}
```

# Actor output Schema

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

The merged items without duplicates, one dataset item per unique item, with the same fields as in your input datasets.

## `summary` (type: `string`):

SUMMARY record: per dataset how many items were read, returned, removed as duplicates and skipped as seen in earlier runs.

# 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("justaduck/dedup-datasets-new-items").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("justaduck/dedup-datasets-new-items").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 justaduck/dedup-datasets-new-items --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,justaduck/dedup-datasets-new-items"
        }
    }
}
```

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/L7HdhSwQ7Q9pjIPPQ/builds/MRqqrb1QTCRtBh4wZ/openapi.json
