{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge Datasets & Remove Duplicates – Join & Dedupe CSV, Excel",
    "description": "Merge Apify datasets, CSV and Excel files into one table and remove duplicates by any fields. Join two tables by key (VLOOKUP: left, inner, full, anti), compare two runs (added, removed, changed), or get only new items since the last run. Export CSV, XLSX, JSON. $0.20 per 1,000 rows.",
    "version": "0.1",
    "x-build-id": "Jelb5EU34KaT19LMV"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/gazidev~dataset-merge-dedupe/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-gazidev-dataset-merge-dedupe",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/gazidev~dataset-merge-dedupe/runs": {
      "post": {
        "operationId": "runs-sync-gazidev-dataset-merge-dedupe",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/gazidev~dataset-merge-dedupe/run-sync": {
      "post": {
        "operationId": "run-sync-gazidev-dataset-merge-dedupe",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "title": "What to do",
            "enum": [
              "merge",
              "join",
              "compare"
            ],
            "type": "string",
            "description": "Merge: put all sources into one table and remove duplicates. Join: add columns from a second table by key (like VLOOKUP / SQL join). Compare: list added, removed and changed rows between two tables.",
            "default": "merge"
          },
          "datasetIds": {
            "title": "Apify datasets",
            "type": "array",
            "description": "Datasets to merge, e.g. the output of several scraper runs. For join: the left table. For compare: the old version. In an integration use {{resource.defaultDatasetId}}."
          },
          "fileUrls": {
            "title": "File URLs (CSV, Excel, JSON)",
            "type": "array",
            "description": "Public links to CSV, TSV, XLSX, XLS, ODS, JSON or JSON Lines files. Google Sheets / Drive (shared with 'Anyone with the link'), Dropbox, OneDrive and GitHub links work. The example has two versions of the same public table (344 rows each).",
            "items": {
              "type": "string"
            }
          },
          "items": {
            "title": "Or paste JSON rows",
            "type": "array",
            "description": "Optional JSON array of objects, added to the datasets and files above. Handy for AI agents."
          },
          "removeDuplicates": {
            "title": "Remove duplicates",
            "type": "boolean",
            "description": "Merge mode: without fields below, rows that are identical in every field are removed. Join mode: duplicates are only removed when you list fields below.",
            "default": true
          },
          "dedupeFields": {
            "title": "Duplicate if these fields match",
            "type": "array",
            "description": "E.g. 'url', or 'name' + 'city'. Empty = the whole row must match. Rows where all these fields are empty are always kept.",
            "items": {
              "type": "string"
            }
          },
          "keep": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last",
              "mostComplete",
              "combine"
            ],
            "type": "string",
            "description": "'Combine' keeps the first row and fills its empty fields from the later duplicates.",
            "default": "first"
          },
          "ignoreCase": {
            "title": "Ignore case and spaces in keys",
            "type": "boolean",
            "description": "'ACME Inc ' and 'acme inc' count as the same value (duplicates, join keys and compare keys).",
            "default": true
          },
          "onlyNewItems": {
            "title": "Only new items since last run",
            "type": "boolean",
            "description": "Remembers every delivered row in a named key-value store and skips it in later runs. Made for scheduled scrapers.",
            "default": false
          },
          "stateStoreName": {
            "title": "Memory name (only new items)",
            "type": "string",
            "description": "Name of the store with the remembered keys. Use a different name for each pipeline.",
            "default": "dataset-merge-dedupe-state"
          },
          "secondDatasetIds": {
            "title": "Second table: Apify datasets",
            "type": "array",
            "description": "Join: the lookup (right) table. Compare: the new version. Not used in merge mode, where all sources are merged."
          },
          "secondFileUrls": {
            "title": "Second table: file URLs",
            "type": "array",
            "description": "CSV, Excel or JSON links for the second table.",
            "items": {
              "type": "string"
            }
          },
          "secondItems": {
            "title": "Second table: JSON rows",
            "type": "array",
            "description": "Optional JSON array of objects for the second table."
          },
          "keyFields": {
            "title": "Key fields",
            "type": "array",
            "description": "Fields that identify the same row in both tables, e.g. 'email' or 'sku'. Required for join. Compare without keys only finds added and removed rows.",
            "items": {
              "type": "string"
            }
          },
          "secondKeyFields": {
            "title": "Key fields in the second table",
            "type": "array",
            "description": "Only when they have other names there, in the same order.",
            "items": {
              "type": "string"
            }
          },
          "joinType": {
            "title": "Join type",
            "enum": [
              "left",
              "inner",
              "full",
              "anti"
            ],
            "type": "string",
            "description": "Left: all rows of table A. Inner: only rows with a match. Full: rows of both tables. Anti: rows of A that have no match in B.",
            "default": "left"
          },
          "joinMatches": {
            "title": "If several rows match",
            "enum": [
              "first",
              "all"
            ],
            "type": "string",
            "description": "First = one output row per row of A, like VLOOKUP. All = one output row per match, like SQL (can create many rows).",
            "default": "first"
          },
          "secondFields": {
            "title": "Columns to add from the second table",
            "type": "array",
            "description": "Empty = all columns.",
            "items": {
              "type": "string"
            }
          },
          "secondPrefix": {
            "title": "Prefix for equal column names",
            "type": "string",
            "description": "Put before columns of the second table whose name also exists in table A.",
            "default": "second_"
          },
          "ignoreFields": {
            "title": "Compare: ignore these fields",
            "type": "array",
            "description": "E.g. 'scrapedAt'. Changes in these fields do not count.",
            "items": {
              "type": "string"
            }
          },
          "includeUnchanged": {
            "title": "Compare: also output unchanged rows",
            "type": "boolean",
            "description": "Off = only added, removed and changed rows.",
            "default": false
          },
          "matchColumnNames": {
            "title": "Match similar column names",
            "type": "boolean",
            "description": "'E-mail', 'email' and 'EMAIL ' from different sources become one column.",
            "default": true
          },
          "addSourceField": {
            "title": "Add _source field",
            "type": "boolean",
            "description": "Adds the dataset ID or file name to each row (merge and join).",
            "default": true
          },
          "limit": {
            "title": "Max output rows",
            "minimum": 0,
            "type": "integer",
            "description": "0 = no limit. When the limit is reached, reading stops.",
            "default": 0
          },
          "exportFormat": {
            "title": "Also save one file",
            "enum": [
              "none",
              "csv",
              "xlsx",
              "json"
            ],
            "type": "string",
            "description": "Saves the result as a file in the key-value store. The link is in the OUTPUT record.",
            "default": "none"
          },
          "exportFileName": {
            "title": "File name",
            "type": "string",
            "description": "Without extension.",
            "default": "merged-data"
          },
          "maxFileSizeMb": {
            "title": "Max input file size (MB)",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Larger files are skipped.",
            "default": 200
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}