{
  "openapi": "3.0.1",
  "info": {
    "title": "Merge & Deduplicate Datasets: Remove Duplicates, Only New Items",
    "description": "Merge Apify datasets, CSV and JSON files into one, remove duplicates by any field, output only new items since the last run, filter, rename and flatten. $0.10 per 1,000 rows.",
    "version": "0.2",
    "x-build-id": "w4BrHYI99pprmJITV"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/gmyri~dataset-merge-dedup/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-gmyri-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/gmyri~dataset-merge-dedup/runs": {
      "post": {
        "operationId": "runs-sync-gmyri-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/gmyri~dataset-merge-dedup/run-sync": {
      "post": {
        "operationId": "run-sync-gmyri-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 (e.g. outputs of your scraper runs). Only the datasets you select here are readable by the Actor."
          },
          "fileUrls": {
            "title": "CSV / JSON / JSONL file URLs",
            "type": "array",
            "description": "Direct links to CSV, TSV, JSON (array or {items:[...]}) or JSON Lines files. Google Sheets 'Publish to web → CSV' links work.",
            "items": {
              "type": "string"
            }
          },
          "inlineItems": {
            "title": "Inline items (JSON array)",
            "type": "array",
            "description": "Rows passed directly, handy for AI agents and quick tests."
          },
          "deduplicate": {
            "title": "Remove duplicates",
            "type": "boolean",
            "description": "Drop rows that share the same dedup key.",
            "default": true
          },
          "dedupFields": {
            "title": "Dedup fields",
            "type": "array",
            "description": "Fields that define a duplicate, e.g. 'url' or 'title' + 'address.city' (dot paths supported). Empty = compare the whole row. Rows where all dedup fields are empty are always kept.",
            "items": {
              "type": "string"
            }
          },
          "dedupCaseInsensitive": {
            "title": "Case-insensitive",
            "type": "boolean",
            "description": "'ACME Ltd' equals 'acme ltd'.",
            "default": true
          },
          "dedupTrimWhitespace": {
            "title": "Ignore extra whitespace",
            "type": "boolean",
            "description": "Collapse and trim whitespace before comparing.",
            "default": true
          },
          "keepOccurrence": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "With 'last', later sources overwrite earlier ones.",
            "default": "first"
          },
          "onlyNewItems": {
            "title": "Only output rows not seen in previous runs",
            "type": "boolean",
            "description": "Incremental mode for scheduled scrapes: remembers dedup keys in a named key-value store and skips rows already output before.",
            "default": false
          },
          "stateStoreName": {
            "title": "State store name",
            "type": "string",
            "description": "Named key-value store that keeps the remembered keys. Use a different name per pipeline.",
            "default": "dataset-dedup-state"
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "All must match. Each filter: {\"field\": \"price\", \"op\": \"lt\", \"value\": 100}. Ops: eq, ne, contains, notContains, in, notIn, gt, gte, lt, lte, exists, notExists, regex."
          },
          "pickFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Output only these fields (dot paths allowed). Empty = keep all.",
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Remove fields",
            "type": "array",
            "description": "Fields to drop.",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "Map of old name to new name, e.g. {\"address.city\": \"city\"}."
          },
          "flattenNested": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "Turn {\"a\":{\"b\":1}} into {\"a.b\":1}. Useful before CSV export.",
            "default": false
          },
          "trimStrings": {
            "title": "Trim strings",
            "type": "boolean",
            "description": "Collapse whitespace in all string values.",
            "default": false
          },
          "dropEmptyFields": {
            "title": "Drop empty fields",
            "type": "boolean",
            "description": "Remove null, empty-string and empty list/object values.",
            "default": false
          },
          "addSourceField": {
            "title": "Add _source field",
            "type": "boolean",
            "description": "Record which dataset or file each row came from.",
            "default": false
          },
          "inferCsvTypes": {
            "title": "Infer numbers/booleans in CSV",
            "type": "boolean",
            "description": "Convert '12', '3.5', 'true' in CSV cells to numbers/booleans.",
            "default": true
          },
          "maxOutputItems": {
            "title": "Max output rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many output rows (0 = no limit).",
            "default": 0
          },
          "saveCsvFile": {
            "title": "Also save OUTPUT.csv",
            "type": "boolean",
            "description": "Save the result as a CSV file in the key-value store (flattened).",
            "default": false
          },
          "saveJsonFile": {
            "title": "Also save OUTPUT.json",
            "type": "boolean",
            "description": "Save the result as one JSON file in the key-value store.",
            "default": false
          },
          "maxFileSizeMb": {
            "title": "Max file size (MB)",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Larger files are skipped.",
            "default": 200
          },
          "requestTimeoutSecs": {
            "title": "Download timeout (s)",
            "minimum": 5,
            "maximum": 900,
            "type": "integer",
            "description": "Timeout per file download.",
            "default": 120
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}