{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge Datasets: Deduplicate, Filter & Transform Apify Data",
    "description": "Merge several Apify datasets into one, remove duplicates by any fields, filter rows, and rename or drop columns. Streams the data, so large datasets do not crash it.",
    "version": "1.0",
    "x-build-id": "6NRA7CqQeCisIJtbV"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/registrydata~dataset-merge-dedup-transform/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-registrydata-dataset-merge-dedup-transform",
        "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/registrydata~dataset-merge-dedup-transform/runs": {
      "post": {
        "operationId": "runs-sync-registrydata-dataset-merge-dedup-transform",
        "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/registrydata~dataset-merge-dedup-transform/run-sync": {
      "post": {
        "operationId": "run-sync-registrydata-dataset-merge-dedup-transform",
        "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",
            "type": "array",
            "description": "The datasets to merge, in priority order. Records from earlier datasets win when duplicates are found and \"Keep\" is set to \"first\". Leave empty to run a demo on two small bundled sample datasets."
          },
          "extraDatasetIds": {
            "title": "Extra dataset IDs",
            "type": "array",
            "description": "Optional. Dataset IDs, names or Console URLs, for example the default dataset ID passed to this Actor by an integration. The Actor must be allowed to read them.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "dedupeFields": {
            "title": "Fields that identify a duplicate",
            "type": "array",
            "description": "Two records are duplicates when all of these fields are equal. Use dots for nested fields, for example <code>address.city</code>. Leave empty to treat records as duplicates only when every field is identical.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "keep": {
            "title": "Keep",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "Which record to keep from a group of duplicates. \"last\" needs a second pass over the data and takes about twice as long.",
            "default": "first"
          },
          "ignoreCase": {
            "title": "Ignore letter case",
            "type": "boolean",
            "description": "Compare text values without regard to upper or lower case when looking for duplicates.",
            "default": false
          },
          "trimWhitespace": {
            "title": "Ignore leading and trailing spaces",
            "type": "boolean",
            "description": "Strip leading and trailing whitespace from text values when comparing records.",
            "default": true
          },
          "keepItemsWithMissingKey": {
            "title": "Keep records missing a key field",
            "type": "boolean",
            "description": "When on, a record that lacks one of the duplicate fields is treated as unique and kept. When off, a missing field counts as null, so such records can be removed as duplicates of each other.",
            "default": true
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "Keep only records that match. Each filter has a <code>field</code>, an <code>operator</code> (equals, notEquals, contains, notContains, startsWith, endsWith, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, matchesRegex, exists, notExists, isEmpty, isNotEmpty) and a <code>value</code>.",
            "default": []
          },
          "filterMode": {
            "title": "Filter mode",
            "enum": [
              "all",
              "any"
            ],
            "type": "string",
            "description": "\"all\" keeps records that match every filter; \"any\" keeps records that match at least one.",
            "default": "all"
          },
          "pickFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Optional. When set, output records contain only these fields. Use dots for nested fields.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Remove these fields",
            "type": "array",
            "description": "Optional. Fields to drop from every output record, for example internal IDs or raw HTML.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "Optional. Map of old field name to new field name, for example <code>{\"fullName\": \"name\"}</code>.",
            "default": {}
          },
          "addSourceField": {
            "title": "Add source dataset field",
            "type": "boolean",
            "description": "Add a field that records which dataset each output record came from.",
            "default": false
          },
          "sourceFieldName": {
            "title": "Source field name",
            "type": "string",
            "description": "Name of the field added when \"Add source dataset field\" is on.",
            "default": "source_dataset"
          },
          "maxItems": {
            "title": "Maximum output records",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after writing this many records. 0 means no limit. Use it to cap the cost of a run.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}