{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge & Dedupe Datasets: Combine, Filter, Export CSV/XLSX",
    "description": "Merge several Apify datasets into one, remove duplicate rows on any key, filter and rename fields, and export CSV or XLSX. Optional only-new-rows mode for repeat jobs. $0.50 per 1,000 rows; duplicates and filtered rows are free.",
    "version": "1.0",
    "x-build-id": "XKHF0fgfQi0OCdpGH"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/mossfetch~dataset-merge-dedupe/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-mossfetch-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/mossfetch~dataset-merge-dedupe/runs": {
      "post": {
        "operationId": "runs-sync-mossfetch-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/mossfetch~dataset-merge-dedupe/run-sync": {
      "post": {
        "operationId": "run-sync-mossfetch-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": {
          "demo": {
            "title": "Demo mode (built-in sample data)",
            "type": "boolean",
            "description": "Run on 2 built-in sample datasets (about 200 rows). Free, needs no dataset IDs. Ignored when you add dataset IDs, so your own data always wins.",
            "default": true
          },
          "datasetIds": {
            "title": "Dataset IDs",
            "type": "array",
            "description": "Apify datasets to merge, in order. Pick datasets from your account or paste dataset IDs. The actor gets read access to these datasets only. When you add any, demo mode is ignored. Example: [\"Zq1abc...\", \"Xy2def...\"]."
          },
          "dedupeKeys": {
            "title": "Dedupe keys",
            "type": "array",
            "description": "Rows with the same values in ALL these fields are duplicates. Dot paths work (address.city). Leave empty for no dedupe (unless 'Dedupe on all fields' is on).",
            "items": {
              "type": "string"
            }
          },
          "dedupeAllFields": {
            "title": "Dedupe on all fields",
            "type": "boolean",
            "description": "With no dedupe keys, treat rows as duplicates only when every field matches.",
            "default": false
          },
          "keepOnly": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "Keep the first or the last row of each duplicate group. 'last' holds all rows in memory.",
            "default": "first"
          },
          "caseInsensitive": {
            "title": "Ignore letter case when comparing",
            "type": "boolean",
            "description": "Treat \"ACME\" and \"acme\" as the same key value.",
            "default": false
          },
          "trimWhitespace": {
            "title": "Ignore extra whitespace when comparing",
            "type": "boolean",
            "description": "Trim and collapse spaces in key values before comparing, so \" a  b \" matches \"a b\".",
            "default": true
          },
          "dropRowsMissingKey": {
            "title": "Drop rows missing a dedupe key",
            "type": "boolean",
            "description": "Rows where a dedupe key field is empty cannot be compared. By default they are kept; switch on to drop them.",
            "default": false
          },
          "onlyNewItems": {
            "title": "Only new items since last run",
            "type": "boolean",
            "description": "Output only rows whose key was not seen in earlier runs. Keys are remembered as hashes in a named key-value store. With no dedupe keys the whole row is the key.",
            "default": false
          },
          "stateKey": {
            "title": "State name",
            "type": "string",
            "description": "Separate 'only new items' memory per use case. Use the same name on every run of the same job.",
            "default": "default"
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "Keep only rows matching ALL filters. Each is {\"field\": \"price\", \"op\": \"gte\", \"value\": 10}. Ops: equals, notEquals, contains, notContains, gt, gte, lt, lte, in, exists, notExists."
          },
          "keepFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Output only these fields (dot paths allowed). Leave empty to keep all. Example: [\"url\", \"title\"].",
            "items": {
              "type": "string"
            }
          },
          "dropFields": {
            "title": "Drop these fields",
            "type": "array",
            "description": "Remove these fields from every row. Ignored when 'Keep only these fields' is set. Example: [\"url\", \"title\"].",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "Map old names to new names, e.g. {\"title\": \"name\"}."
          },
          "addSourceField": {
            "title": "Add source dataset field",
            "type": "boolean",
            "description": "Add _sourceDataset to each row.",
            "default": false
          },
          "exportFormats": {
            "title": "Also export files",
            "type": "array",
            "description": "Save the result as CSV and/or XLSX in the key-value store (OUTPUT.csv, OUTPUT.xlsx). The dataset is always written. Example: [\"csv\", \"xlsx\"].",
            "items": {
              "type": "string",
              "enum": [
                "csv",
                "xlsx"
              ]
            }
          },
          "maxRows": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many output rows. 0 means no limit.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}