{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Merge, Dedup, Filter & Export to CSV/Excel",
    "description": "Merge Apify datasets, remove duplicates by any fields (nested too), filter without code, pick/rename/flatten fields, keep only new items across runs, and export one CSV, Excel or JSON file. Streams millions of items, works with limited permissions and as an integration.",
    "version": "0.1",
    "x-build-id": "Dn5ZfMRm4cTWbVy9M"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/xdavidt~dataset-merge-dedup-export/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-xdavidt-dataset-merge-dedup-export",
        "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/xdavidt~dataset-merge-dedup-export/runs": {
      "post": {
        "operationId": "runs-sync-xdavidt-dataset-merge-dedup-export",
        "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/xdavidt~dataset-merge-dedup-export/run-sync": {
      "post": {
        "operationId": "run-sync-xdavidt-dataset-merge-dedup-export",
        "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": {
          "datasetIds": {
            "title": "Datasets",
            "type": "array",
            "description": "One or more datasets to process, merged in this order. Pick them, or pass dataset IDs or names via API. As an integration after another Actor, use {\"datasetIds\": [\"{{resource.defaultDatasetId}}\"]}."
          },
          "dedupeFields": {
            "title": "Deduplicate by fields",
            "type": "array",
            "description": "Fields whose combined value must be unique, e.g. url, or title + address.city. Nested paths like author.name or images[0].url work. Leave empty for no deduplication.",
            "items": {
              "type": "string"
            }
          },
          "dedupeWholeItem": {
            "title": "Deduplicate by whole item",
            "type": "boolean",
            "description": "When no dedupe fields are set, treat two items as duplicates only if all their fields are equal (key order does not matter).",
            "default": false
          },
          "dedupeCaseInsensitive": {
            "title": "Ignore letter case",
            "type": "boolean",
            "description": "Treat \"ACME Inc\" and \"acme inc\" as the same value.",
            "default": false
          },
          "dedupeTrim": {
            "title": "Ignore extra whitespace",
            "type": "boolean",
            "description": "Trim and collapse whitespace before comparing.",
            "default": true
          },
          "dedupeNormalizeUrls": {
            "title": "Normalize URLs",
            "type": "boolean",
            "description": "Compare URLs without protocol, www., trailing slash, #hash and tracking parameters (utm_*, fbclid, gclid, ref).",
            "default": false
          },
          "keepItemsWithoutKey": {
            "title": "Keep items with empty dedupe fields",
            "type": "boolean",
            "description": "If all dedupe fields of an item are empty or missing, keep it instead of collapsing all such items into one.",
            "default": true
          },
          "output": {
            "title": "Output",
            "enum": [
              "unique",
              "duplicates",
              "none"
            ],
            "type": "string",
            "description": "What to write to the output.",
            "default": "unique"
          },
          "excludeDatasetIds": {
            "title": "Skip items already in these datasets",
            "type": "array",
            "description": "Items whose dedupe key appears in these datasets are not output. Use it to get only new items compared with a previous result."
          },
          "historyKey": {
            "title": "Remember across runs (history key)",
            "type": "string",
            "description": "Give a name, e.g. my-daily-jobs. Every run with the same key outputs only items never seen in previous runs, which is ideal for scheduled scrapers. Keys are stored as 8-byte hashes in a named key-value store in your account (dataset-utility-history)."
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "Keep only items matching the rules. Each rule: {\"field\": \"price\", \"op\": \"lt\", \"value\": 100}. Ops: equals, notEquals, contains, notContains, startsWith, endsWith, regex, notRegex, gt, gte, lt, lte, in, notIn, exists, notExists, isEmpty, notEmpty. Text comparisons ignore case unless \"caseSensitive\": true. Numbers like \"$1,200\" and dates are compared numerically."
          },
          "filterLogic": {
            "title": "Combine filters with",
            "enum": [
              "and",
              "or"
            ],
            "type": "string",
            "description": "AND: an item must match every rule. OR: any rule is enough.",
            "default": "and"
          },
          "pickFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Output only these fields (nested paths allowed, e.g. address.city). Also speeds up the run, because only the needed fields are downloaded.",
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Remove these fields",
            "type": "array",
            "description": "Drop these fields from the output (nested paths allowed).",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "Map of old path to new path, e.g. {\"title\": \"name\", \"location.city\": \"city\"}."
          },
          "flattenOutput": {
            "title": "Flatten nested fields",
            "type": "boolean",
            "description": "Turn {\"address\": {\"city\": \"X\"}} into {\"address.city\": \"X\"}. Exports to CSV and Excel are always flattened.",
            "default": false
          },
          "arrayMode": {
            "title": "Arrays in flattened output",
            "enum": [
              "join",
              "columns",
              "json"
            ],
            "type": "string",
            "description": "How arrays become columns when flattening and in CSV/Excel.",
            "default": "join"
          },
          "addSourceDatasetId": {
            "title": "Add source dataset ID",
            "type": "boolean",
            "description": "Add a __sourceDatasetId field to every item, showing which dataset it came from.",
            "default": false
          },
          "preProcessFunction": {
            "title": "Pre-process function (optional)",
            "type": "string",
            "description": "JavaScript run on each input item before filters and dedupe. Return the item (modified), null to drop it, or an array to split it into several items. Second argument: { source, index }."
          },
          "postProcessFunction": {
            "title": "Post-process function (optional)",
            "type": "string",
            "description": "JavaScript run on each output item after dedupe and field shaping. Return the item, null to drop it, or an array."
          },
          "writeToDefaultDataset": {
            "title": "Write results to this run's dataset",
            "type": "boolean",
            "description": "Store output items in the run's default dataset (downloadable as CSV, Excel, JSON, XML from the Console or API).",
            "default": true
          },
          "outputDatasetId": {
            "title": "Also append to dataset (optional)",
            "type": "string",
            "description": "Append the output to an existing dataset of yours, e.g. a master list that grows with every run."
          },
          "exportFormats": {
            "title": "Export files",
            "type": "array",
            "description": "Also save the output as single files in the run's key-value store, with links in OUTPUT. CSV is UTF-8 with BOM, so Excel shows Hebrew, Arabic, Chinese and accents correctly. XLSX splits into extra sheets beyond 1,048,575 rows.",
            "items": {
              "type": "string",
              "enum": [
                "csv",
                "xlsx",
                "json",
                "jsonl"
              ],
              "enumTitles": [
                "CSV",
                "Excel (XLSX)",
                "JSON",
                "JSON Lines"
              ]
            },
            "default": []
          },
          "exportFileName": {
            "title": "Export file name",
            "type": "string",
            "description": "Base name for exported files (without extension).",
            "default": "output"
          },
          "csvDelimiter": {
            "title": "CSV delimiter",
            "enum": [
              ",",
              ";",
              "\t",
              "|"
            ],
            "type": "string",
            "description": "Column separator for CSV. Use ; for Excel in many European locales.",
            "default": ","
          },
          "offset": {
            "title": "Skip first N items",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many items from the start of the merged input.",
            "default": 0
          },
          "limit": {
            "title": "Read at most N items",
            "minimum": 1,
            "type": "integer",
            "description": "Stop reading after this many input items. Empty = all."
          },
          "maxOutputItems": {
            "title": "Output at most N items",
            "minimum": 1,
            "type": "integer",
            "description": "Stop after writing this many items. Useful to cap cost."
          },
          "skipHiddenFields": {
            "title": "Clean items (skip hidden fields and empty items)",
            "type": "boolean",
            "description": "Drop fields starting with # and empty items, as the Console's \"clean\" export does.",
            "default": false
          },
          "pageSize": {
            "title": "Download page size",
            "minimum": 100,
            "maximum": 50000,
            "type": "integer",
            "description": "Items per API request. Lower it if your items are very large (several hundred KB each).",
            "default": 5000
          },
          "payload": {
            "title": "Integration payload",
            "type": "object",
            "description": "Filled in automatically when this Actor runs as an integration or from a webhook; the triggering run's dataset is processed."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}