{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge & Deduplicate Datasets – Filter, Pick, Rename",
    "description": "Merge and deduplicate Apify datasets with limited permissions: remove duplicates by key fields (trim, case and URL normalization), keep first or last, filter, pick and rename fields, append only new rows to a named dataset. $0.30 per 1,000 rows written; only written rows are charged.",
    "version": "0.1",
    "x-build-id": "cX5aMrTG967kBuG9k"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/klarto~dataset-merge-dedup/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-klarto-dataset-merge-dedup",
        "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/klarto~dataset-merge-dedup/runs": {
      "post": {
        "operationId": "runs-sync-klarto-dataset-merge-dedup",
        "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/klarto~dataset-merge-dedup/run-sync": {
      "post": {
        "operationId": "run-sync-klarto-dataset-merge-dedup",
        "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": {
          "datasets": {
            "title": "Datasets to merge",
            "type": "array",
            "description": "Datasets in merge order: rows are read from the first dataset, then the second, and so on. Picking a dataset gives this Actor read access to it (limited permissions). Through the API pass dataset IDs or names. Leave empty for a demo on 15 built-in sample rows (rows not charged)."
          },
          "removeDuplicates": {
            "title": "Remove duplicates",
            "type": "boolean",
            "description": "Turn off to only merge, filter and reshape rows without comparing them.",
            "default": true
          },
          "dedupFields": {
            "title": "Dedup fields",
            "type": "array",
            "description": "Rows with equal values in all these fields are duplicates, e.g. url, or email + company. Use dots for nested fields (address.city) and numbers for list items (emails.0). Leave empty to compare whole rows as they will be written (after 'Keep only these fields', 'Remove these fields' and renames; field order does not matter).",
            "items": {
              "type": "string"
            }
          },
          "normalize": {
            "title": "Normalize values before comparing",
            "type": "array",
            "description": "Used only for comparing; rows are written unchanged. URL rules apply to values with a scheme (https://), starting with www., or a domain with a path (example.com/about); plain text such as St.Louis is not changed. They ignore scheme, www., default port, #fragment, trailing slash and utm_*/gclid/fbclid, lowercase the host and sort other parameters. Empty = exact match. 1 and 1.0 always count as the same number.",
            "items": {
              "type": "string",
              "enum": [
                "trim",
                "lowercase",
                "url"
              ],
              "enumTitles": [
                "Trim and collapse spaces",
                "Ignore letter case",
                "Normalize URLs and domains"
              ]
            },
            "default": []
          },
          "keep": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "First: the first row of each key is kept. Last: the last row in merge order is kept, at its own position (two passes over the data).",
            "default": "first"
          },
          "emptyDedupFields": {
            "title": "Rows whose dedup fields are all empty",
            "enum": [
              "keep",
              "drop",
              "dedupe"
            ],
            "type": "string",
            "description": "A row counts as empty here when every dedup field is missing, null, empty text, an empty list or an empty object (with 'trim' normalization, text of only spaces too). Such rows are kept by default, so no data is lost silently.",
            "default": "keep"
          },
          "output": {
            "title": "What to write",
            "enum": [
              "unique",
              "duplicates",
              "countOnly"
            ],
            "type": "string",
            "description": "Count only writes no rows and charges no rows: the counts are in the run's status and the OUTPUT record. 'Only the removed duplicates' writes (and charges) the rows removed as duplicates inside the input, not rows found in skip datasets, and cannot be combined with 'Only new rows'.",
            "default": "unique"
          },
          "outputDataset": {
            "title": "Append to dataset (optional)",
            "type": "string",
            "description": "Leave empty to write to this run's default dataset. Pick a dataset, or give a new name through the API (it is created), to append the rows to it. A name of exactly 17 letters and digits looks like an ID: write it as ~name."
          },
          "skipExistingInOutput": {
            "title": "Only new rows (skip rows already in the output dataset)",
            "type": "boolean",
            "description": "Needs 'Append to dataset'. Rows whose key is already in that dataset are skipped, so a scheduled run adds only new rows. Key fields are matched under their renamed names; a row whose key fields are all empty is skipped when the same whole row is already there.",
            "default": false
          },
          "excludeDatasets": {
            "title": "Skip rows found in these datasets",
            "type": "array",
            "description": "Rows whose key appears in any of these datasets are not written (for example last week's leads). Compared with the same key fields and normalization."
          },
          "fields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Write only these fields, in this order. Missing ones are written as null, so every row has the same columns. Dots pick nested fields (address.city keeps {address: {city}}); a path with a number in it (emails.0, stats.2024) is one column with that literal name. Empty = all fields.",
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Remove these fields",
            "type": "array",
            "description": "Fields to drop from every row (dots for nested fields).",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "array",
            "description": "Old name -> new name. A dot in the new name nests the value (city -> location.city). An existing field with the new name is replaced. Applied after 'Keep only these fields' and 'Remove these fields', which use the original names.",
            "items": {
              "type": "object",
              "required": [
                "key",
                "value"
              ],
              "properties": {
                "key": {
                  "type": "string",
                  "title": "Key"
                },
                "value": {
                  "type": "string",
                  "title": "Value"
                }
              }
            }
          },
          "filters": {
            "title": "Filters (a row must match all)",
            "maxItems": 20,
            "type": "array",
            "description": "Rows that do not match are not written and not charged. Filters see the original rows.",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "title": "Field",
                  "type": "string",
                  "editor": "textfield",
                  "description": "Field name or dot path"
                },
                "operator": {
                  "title": "Operator",
                  "type": "string",
                  "editor": "select",
                  "enum": [
                    "exists",
                    "notExists",
                    "equals",
                    "notEquals",
                    "contains",
                    "notContains",
                    "greaterThan",
                    "lessThan"
                  ],
                  "enumTitles": [
                    "exists (not empty)",
                    "is missing or empty",
                    "equals",
                    "does not equal",
                    "contains",
                    "does not contain",
                    "greater than (number)",
                    "less than (number)"
                  ],
                  "description": "Text comparisons ignore case and surrounding spaces; numbers compare as numbers; a list matches when one of its items matches."
                },
                "value": {
                  "title": "Value",
                  "type": "string",
                  "editor": "textfield",
                  "description": "Not needed for exists / is missing"
                }
              },
              "required": [
                "field",
                "operator"
              ]
            }
          },
          "addSourceDatasetId": {
            "title": "Add the source dataset to each row",
            "type": "boolean",
            "description": "Adds a field sourceDatasetId with the name (or ID) of the dataset the row came from.",
            "default": false
          },
          "maxOutputRows": {
            "title": "Max rows to write",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many rows (0 = no limit). Useful for a cheap test.",
            "default": 0
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}