{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Merge, Dedupe & Transform - CSV, JSON, XLSX",
    "description": "Merge Apify datasets, CSV and JSON files, remove duplicates by chosen fields, filter and rename columns, keep only new items, export CSV or XLSX.",
    "version": "0.1",
    "x-build-id": "S8wy5l8CCgEMPIkAs"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/rinveta~dataset-merge-dedupe/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-rinveta-dataset-merge-dedupe",
        "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/rinveta~dataset-merge-dedupe/runs": {
      "post": {
        "operationId": "runs-sync-rinveta-dataset-merge-dedupe",
        "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/rinveta~dataset-merge-dedupe/run-sync": {
      "post": {
        "operationId": "run-sync-rinveta-dataset-merge-dedupe",
        "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 dataset IDs or names",
            "type": "array",
            "description": "Datasets to merge (for example the default dataset of other Actor runs). Order is kept: with 'keep first' the earliest source wins."
          },
          "sourceUrls": {
            "title": "CSV / JSON file URLs",
            "type": "array",
            "description": "Public links to CSV, TSV, JSON (array), or JSON Lines files. Format is detected automatically. Only the URLs you list are downloaded.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "jsonPath": {
            "title": "JSON path to the list (optional)",
            "type": "string",
            "description": "For JSON files whose items are nested, e.g. 'data.results'. Empty = auto-detect."
          },
          "csvDelimiter": {
            "title": "CSV delimiter (optional)",
            "type": "string",
            "description": "Leave empty to auto-detect among , ; tab |."
          },
          "csvInferTypes": {
            "title": "Convert numbers and booleans in CSV",
            "type": "boolean",
            "description": "Turn '42' into a number and 'true' into a boolean. Values with leading zeros (e.g. '007') stay text. Empty cells become null.",
            "default": true
          },
          "dedupeFields": {
            "title": "Dedupe by these fields",
            "type": "array",
            "description": "Items with the same values in ALL these fields are duplicates. Use dot notation for nested fields (e.g. 'address.city'). Empty list = compare whole items.",
            "items": {
              "type": "string"
            }
          },
          "dedupeTrim": {
            "title": "Ignore extra spaces when comparing",
            "type": "boolean",
            "description": "Remove leading and trailing spaces from the dedupe fields before comparing them.",
            "default": true
          },
          "dedupeIgnoreCase": {
            "title": "Ignore upper/lower case when comparing",
            "type": "boolean",
            "description": "Treat 'ABC' and 'abc' as the same value when looking for duplicates.",
            "default": true
          },
          "keepItemsWithEmptyKey": {
            "title": "Keep items whose dedupe fields are all empty",
            "type": "boolean",
            "description": "On: such items are never treated as duplicates of each other. Off: they all collapse into one.",
            "default": true
          },
          "keepStrategy": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last",
              "mostComplete"
            ],
            "type": "string",
            "description": "When duplicates are found: keep the first one seen, the last one seen, or the one with the most non-empty fields.",
            "default": "first"
          },
          "onlyNewItems": {
            "title": "Output only items not seen in previous runs",
            "type": "boolean",
            "description": "Remembers the dedupe keys of everything already output (stored in a named key-value store in YOUR account) and returns only new ones. Perfect for scheduled monitoring.",
            "default": false
          },
          "stateKey": {
            "title": "State name",
            "type": "string",
            "description": "Separate memory per use case. Use different names for different jobs.",
            "default": "default"
          },
          "updateState": {
            "title": "Remember this run's items",
            "type": "boolean",
            "description": "Turn off for a dry run that does not change the stored memory.",
            "default": true
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "Array of {\"field\":\"price\",\"op\":\"gte\",\"value\":10}. Operators: eq, neq, contains, notContains, startsWith, gt, gte, lt, lte, regex, in, exists, notExists."
          },
          "filterMode": {
            "title": "Filter mode",
            "enum": [
              "all",
              "any"
            ],
            "type": "string",
            "description": "With several filters: 'all' keeps items that match every filter, 'any' keeps items that match at least one.",
            "default": "all"
          },
          "includeFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Output column order. Empty = keep all fields.",
            "items": {
              "type": "string"
            }
          },
          "excludeFields": {
            "title": "Remove these fields",
            "type": "array",
            "description": "Fields to remove from every output item. Applied after the filters.",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "{\"oldName\":\"newName\"}. Applied after filtering and deduping, so use the original names above."
          },
          "flattenNested": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "{address:{city:'X'}} becomes 'address.city'. Recommended for CSV/XLSX.",
            "default": false
          },
          "trimStrings": {
            "title": "Trim text values",
            "type": "boolean",
            "description": "Remove leading and trailing spaces from all text values in each item.",
            "default": false
          },
          "addSourceField": {
            "title": "Add source columns",
            "type": "boolean",
            "description": "Adds _source and _sourceIndex so you can see where each kept item came from.",
            "default": false
          },
          "sortBy": {
            "title": "Sort by field (optional)",
            "type": "string",
            "description": "Field name used to sort the output. Leave empty to keep the input order."
          },
          "sortOrder": {
            "title": "Sort order",
            "enum": [
              "asc",
              "desc"
            ],
            "type": "string",
            "description": "Ascending or descending order, used only when 'Sort by field' is set.",
            "default": "asc"
          },
          "exportFormats": {
            "title": "Extra export files",
            "type": "array",
            "description": "Also write OUTPUT.csv and/or OUTPUT.xlsx to the run's key-value store.",
            "items": {
              "type": "string",
              "enum": [
                "csv",
                "xlsx"
              ],
              "enumTitles": [
                "CSV",
                "Excel (XLSX)"
              ]
            },
            "default": []
          },
          "maxItems": {
            "title": "Max output items (0 = unlimited)",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many output items. 0 means no limit. Only the items returned (and charged) count.",
            "default": 0
          },
          "maxItemsPerSource": {
            "title": "Max items read per source (0 = all)",
            "minimum": 0,
            "type": "integer",
            "description": "Read at most this many items from each dataset or file. 0 reads everything.",
            "default": 0
          },
          "maxFileSizeMB": {
            "title": "Max file size (MB)",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Skip any URL source larger than this size, to protect memory and compute cost.",
            "default": 100
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}