{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge Datasets & Remove Duplicates: CSV, JSON, Apify",
    "description": "Merge Apify datasets and CSV/JSON/JSONL files into one dataset and remove duplicates. Use to combine scraper outputs or exports. Input: datasetIds and/or fileUrls, dedupFields, optional renameFields, filters, keepFields. Output: merged deduplicated rows (optional _source field) plus a SUMMARY.",
    "version": "0.1",
    "x-build-id": "PSOmegFQesOQiJIhS"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/phaux~dataset-merge-dedup/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-phaux-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/phaux~dataset-merge-dedup/runs": {
      "post": {
        "operationId": "runs-sync-phaux-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/phaux~dataset-merge-dedup/run-sync": {
      "post": {
        "operationId": "run-sync-phaux-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": {
          "datasetIds": {
            "title": "Apify datasets",
            "type": "array",
            "description": "Datasets to merge, in order. In Console pick them with the dataset picker; via API pass dataset IDs (or 'username~dataset-name'). Only these datasets can be read by the run (read-only access). Example: [\"<dataset ID from a previous run>\"]."
          },
          "fileUrls": {
            "title": "CSV, JSON or JSONL file URLs",
            "type": "array",
            "description": "Public URLs of CSV (any delimiter), JSON (array, or object with an items/data list) or JSON Lines files. Each is downloaded once, up to maxFileSizeMb. Example: [\"https://raw.githubusercontent.com/datasets/country-list/main/data.csv\", \"https://raw.githubusercontent.com/datasets/country-codes/main/data/country-codes.csv\"].",
            "items": {
              "type": "string"
            }
          },
          "dedupFields": {
            "title": "Deduplicate by fields",
            "type": "array",
            "description": "Rows with the same values in all these fields count as duplicates; the first one is kept. Dot paths work for nested fields (e.g. 'address.city'). Rows where all of these fields are empty are always kept. Leave empty for no field-based dedup.",
            "items": {
              "type": "string"
            }
          },
          "dedupWholeItem": {
            "title": "Deduplicate identical rows",
            "type": "boolean",
            "description": "When no dedup fields are set: drop rows that are identical in every field. Default: false.",
            "default": false
          },
          "caseInsensitive": {
            "title": "Case-insensitive matching",
            "type": "boolean",
            "description": "Ignore letter case (and surrounding spaces) when comparing dedup keys and text filters. Default: false.",
            "default": false
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "Map of old top-level field name to new name, e.g. {\"Company Name\": \"company\"}. Applied first. Map several source names to one new name to align differently named columns."
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "Keep only rows matching these conditions, e.g. [{\"field\": \"price\", \"op\": \"gt\", \"value\": 10}, {\"field\": \"email\", \"op\": \"notEmpty\"}]. Ops: eq, neq, gt, gte, lt, lte, contains, notContains, startsWith, endsWith, regex, in, notIn, exists, notExists, empty, notEmpty. Numbers in text are compared as numbers."
          },
          "filterMode": {
            "title": "Filter mode",
            "enum": [
              "all",
              "any"
            ],
            "type": "string",
            "description": "all = a row must match every filter; any = at least one. Default: \"all\".",
            "default": "all"
          },
          "keepFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Output only these fields, in this order (dot paths allowed; missing values become null). Leave empty to keep all fields. Example: [\"url\", \"title\", \"price\"].",
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Drop these fields",
            "type": "array",
            "description": "Top-level fields to remove (ignored when keepFields is set). Example: [\"html\", \"debug\"].",
            "items": {
              "type": "string"
            }
          },
          "addSourceField": {
            "title": "Add source field",
            "type": "boolean",
            "description": "Add the dataset ID or file URL each row came from. Default: false.",
            "default": false
          },
          "sourceFieldName": {
            "title": "Source field name",
            "type": "string",
            "description": "Name of the source field. Example: \"_source\". Default: \"_source\".",
            "default": "_source"
          },
          "maxItems": {
            "title": "Max output rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many rows are saved (0 = no limit). Also caps the cost of a run. Default: 0.",
            "default": 0
          },
          "skipHiddenFields": {
            "title": "Skip hidden fields",
            "type": "boolean",
            "description": "Drop fields starting with # from dataset rows (Apify's hidden-field convention). Default: false.",
            "default": false
          },
          "csvDelimiter": {
            "title": "CSV delimiter",
            "type": "string",
            "description": "auto detects , ; tab or |. Or give one character (use 'tab' for tab). Example: \",\" or \";\". Default: \"auto\".",
            "default": "auto"
          },
          "maxFileSizeMb": {
            "title": "Max file size (MB)",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Per file URL (1–500). Large JSON arrays need about 10x their size in memory; JSON Lines and CSV need less. Raise the run memory for big files. Default: 100.",
            "default": 100
          },
          "failOnSourceError": {
            "title": "Fail if any source fails",
            "type": "boolean",
            "description": "Off: a missing dataset or broken file is reported in SOURCE_ERRORS and the other sources are still merged. On: the run fails at the first broken source. Default: false.",
            "default": false
          },
          "timeBudgetSecs": {
            "title": "Time budget (seconds)",
            "minimum": 0,
            "type": "integer",
            "description": "Stop reading after this many seconds and keep the rows saved so far (0 = only the run timeout guard). Default: 0.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}