{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge & Deduplicate Datasets",
    "description": "Merge several Apify datasets into one and remove duplicate rows by the fields you choose (or whole rows), with optional filters and field selection. Runs with limited permissions: pick datasets in the input, API IDs work too.",
    "version": "1.0",
    "x-build-id": "lOMX1Ru1aDz5a8iU9"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/dojito~merge-dedup-datasets/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-dojito-merge-dedup-datasets",
        "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/dojito~merge-dedup-datasets/runs": {
      "post": {
        "operationId": "runs-sync-dojito-merge-dedup-datasets",
        "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/dojito~merge-dedup-datasets/run-sync": {
      "post": {
        "operationId": "run-sync-dojito-merge-dedup-datasets",
        "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": "The datasets to merge, in order (rows of the first dataset come first). Pick them from your storage, or over the API pass dataset IDs (or username~dataset-name) as strings. Up to 100. When you pick datasets here, the rows in 'Or: rows as JSON' below are ignored."
          },
          "items": {
            "title": "Or: rows as JSON",
            "type": "array",
            "description": "Instead of datasets, paste up to 10,000 rows: an array of row objects, or an array of row arrays (each inner array is merged like one dataset, in order). The two small sample groups (one duplicate URL) are only for trying the actor; when you pick Datasets above, they are ignored."
          },
          "dedupFields": {
            "title": "Deduplicate by fields",
            "type": "array",
            "description": "Rows with the same values in all these fields count as duplicates, e.g. url, or name + city. Nested fields with dots: address.city. Leave empty to compare whole rows. Rows with none of these fields are kept.",
            "items": {
              "type": "string"
            }
          },
          "keep": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "first = the earliest row (in dataset order, then row order). last = the latest row; the datasets are then read twice.",
            "default": "first"
          },
          "normalizeWhitespace": {
            "title": "Ignore extra spaces",
            "type": "boolean",
            "description": "When comparing, trim text and treat runs of spaces / line breaks as one space. The output rows are not changed.",
            "default": true
          },
          "ignoreCase": {
            "title": "Ignore letter case",
            "type": "boolean",
            "description": "When comparing, treat \"ACME\" and \"acme\" as the same. The output rows are not changed.",
            "default": false
          },
          "ignoreTrailingSlash": {
            "title": "Ignore trailing slash in URLs",
            "type": "boolean",
            "description": "When comparing, treat https://example.com/page/ and https://example.com/page as the same. The output rows are not changed.",
            "default": false
          },
          "ignoreFields": {
            "title": "Ignore fields (whole-row mode)",
            "type": "array",
            "description": "Only when 'Deduplicate by fields' is empty: leave these fields out of the comparison, e.g. scrapedAt or a run id that differs between otherwise equal rows. Fields starting with # are always ignored.",
            "items": {
              "type": "string"
            }
          },
          "dedup": {
            "title": "Remove duplicates",
            "type": "boolean",
            "description": "Turn off to only merge (and filter) the datasets.",
            "default": true
          },
          "fields": {
            "title": "Output fields",
            "type": "array",
            "description": "Keep only these fields, in this order (dots reach nested values: address.city). Leave empty to keep the rows as they are.",
            "items": {
              "type": "string"
            }
          },
          "filter": {
            "title": "Filter",
            "type": "array",
            "description": "Keep only rows that match all conditions. Each condition: {\"field\": \"price\", \"op\": \"gt\", \"value\": 10}. op: equals, notEquals, contains, notContains, startsWith, endsWith, in (value = list), gt, gte, lt, lte, exists, notExists, isEmpty, isNotEmpty. Text is compared case-insensitively; gt/lt compare numbers, or text such as ISO dates."
          },
          "addSourceDataset": {
            "title": "Add source dataset ID",
            "type": "boolean",
            "description": "Add a _sourceDataset field: the dataset ID (or username~name) each row came from, exactly as given in Datasets.",
            "default": false
          },
          "maxItems": {
            "title": "Max results",
            "minimum": 1,
            "maximum": 10000000,
            "type": "integer",
            "description": "Stop after this many output rows (you pay per output row). Duplicates and filtered-out rows are free.",
            "default": 100000
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}