{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge & Deduplicate Datasets: Remove Duplicates, Only New Items",
    "description": "Merge Apify datasets, deduplicate and remove duplicates by any fields, with loose URL matching. Keep only items new since an earlier dataset. Run by an AI agent operated by Martin Lenweiter.",
    "version": "0.1",
    "x-build-id": "zPzd7frk7sQHmEAVe"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/lenweiter-ai-agent~dataset-dedup/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-lenweiter-ai-agent-dataset-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/lenweiter-ai-agent~dataset-dedup/runs": {
      "post": {
        "operationId": "runs-sync-lenweiter-ai-agent-dataset-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/lenweiter-ai-agent~dataset-dedup/run-sync": {
      "post": {
        "operationId": "run-sync-lenweiter-ai-agent-dataset-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": "Datasets to merge",
            "type": "array",
            "description": "Choose one or more of your datasets, or paste their IDs. Items are read in this order. Leave empty to try two small bundled samples. This run gets read access to the chosen datasets only."
          },
          "dedupeFields": {
            "title": "Fields that identify a duplicate",
            "type": "array",
            "description": "Two items are duplicates when all these fields match, for example url, or sku and storeId. Use a dot for nested fields (seller.id). Leave empty to compare whole items.",
            "items": {
              "type": "string"
            }
          },
          "itemFilters": {
            "title": "Keep only items where",
            "type": "array",
            "description": "Optional conditions, one per line; an item must meet them all. Written as field operator value, for example: price >= 10, title contains kettle, seller.id exists. Operators: =, !=, >, >=, <, <=, contains, !contains, startsWith, endsWith, matches (a regular expression), exists, missing. contains ignores case. Numbers compare as numbers. Filtered items are not counted as duplicates, and they take no part in the comparison.",
            "items": {
              "type": "string"
            }
          },
          "keep": {
            "title": "Which copy to keep",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "Pick the last copy when later datasets hold newer data.",
            "default": "first"
          },
          "itemsMissingField": {
            "title": "Items with a missing or empty field",
            "enum": [
              "keep",
              "drop"
            ],
            "type": "string",
            "description": "What to do with items that lack a value in one of the fields above. They are counted in the OUTPUT record either way.",
            "default": "keep"
          },
          "ignoreCase": {
            "title": "Ignore upper and lower case",
            "type": "boolean",
            "description": "Blue Kettle and blue kettle count as the same.",
            "default": false
          },
          "ignoreExtraSpaces": {
            "title": "Ignore extra spaces",
            "type": "boolean",
            "description": "Trims text and treats runs of spaces as one space when comparing. The output keeps the original text.",
            "default": false
          },
          "normalizeUrls": {
            "title": "Compare URLs loosely",
            "type": "boolean",
            "description": "Ignores http or https, www, a trailing slash, #fragments and tracking parameters such as utm_source and gclid when comparing. The output keeps the original URL.",
            "default": false
          },
          "excludeItemsFromDatasetIds": {
            "title": "Only new items: compare against these datasets",
            "type": "array",
            "description": "Items also found in these datasets are left out, and these datasets' own items are not output. Use last week's results to keep only what is new."
          },
          "keepFields": {
            "title": "Output only these fields",
            "type": "array",
            "description": "Leave empty to keep all fields. Nested fields become a column named by their path.",
            "items": {
              "type": "string"
            }
          },
          "dropFields": {
            "title": "Or remove these fields",
            "type": "array",
            "description": "Top-level fields to remove from the output. Ignored if the option above is used.",
            "items": {
              "type": "string"
            }
          },
          "addSourceDataset": {
            "title": "Add the source dataset ID",
            "type": "boolean",
            "description": "Adds a __sourceDataset field to each output item.",
            "default": false
          },
          "outputTo": {
            "title": "Where to write the result",
            "enum": [
              "dataset",
              "file"
            ],
            "type": "string",
            "description": "Apify bills dataset writes per item, about $5 per million on the free plan, so writing a large result as a dataset costs more than the rest of the run. Files are gzip JSON Lines in the run's key-value store, and their links are in the OUTPUT record.",
            "default": "dataset"
          },
          "outputDatasetName": {
            "title": "Output dataset name (optional)",
            "type": "string",
            "description": "Also keep the result in a named dataset on your account, which is not deleted after the retention period. Items are appended if it already exists. Leave empty to use the run's default dataset."
          },
          "countOnly": {
            "title": "Count only",
            "type": "boolean",
            "description": "Reports how many items and duplicates there are, and writes no items.",
            "default": false
          },
          "filePartMb": {
            "title": "File part size (MB)",
            "minimum": 1,
            "maximum": 8,
            "type": "integer",
            "description": "Only for compressed files. A new part starts at about this size.",
            "default": 8
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}