{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Toolkit: Merge, Dedupe, Diff & Export to Excel/CSV",
    "description": "Merge or join Apify datasets and CSV/JSON/Excel files, deduplicate, filter, rename fields, normalize emails, phones (E.164) and URLs, compare with a previous run (added / changed / removed) and export to XLSX, CSV, JSONL or JSON.",
    "version": "0.1",
    "x-build-id": "wsj76TU1e9B5K7qzC"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/latamdatatools~dataset-toolkit/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-latamdatatools-dataset-toolkit",
        "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/latamdatatools~dataset-toolkit/runs": {
      "post": {
        "operationId": "runs-sync-latamdatatools-dataset-toolkit",
        "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/latamdatatools~dataset-toolkit/run-sync": {
      "post": {
        "operationId": "run-sync-latamdatatools-dataset-toolkit",
        "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": "Pick one or more datasets (or paste their IDs) from any Actor run. Several datasets are appended or joined."
          },
          "fileUrls": {
            "title": "File URLs (CSV, TSV, JSON, JSONL, XLSX)",
            "type": "array",
            "description": "Public file URLs, up to 100 MB each. Format is detected automatically. Google Sheets links work if shared as \"Anyone with the link\".",
            "items": {
              "type": "string"
            }
          },
          "mergeMode": {
            "title": "Combine sources",
            "enum": [
              "append",
              "join"
            ],
            "type": "string",
            "description": "Append = stack all rows. Join = enrich the first source with the fields of the others, matching on key fields (like a VLOOKUP / SQL join).",
            "default": "append"
          },
          "joinKeys": {
            "title": "Join key fields",
            "type": "array",
            "description": "Fields that identify the same record, e.g. domain or email (case-insensitive).",
            "items": {
              "type": "string"
            }
          },
          "joinKeysRight": {
            "title": "Join key fields in the other sources (if named differently)",
            "type": "array",
            "description": "Optional, same order as above, e.g. website_domain.",
            "items": {
              "type": "string"
            }
          },
          "joinType": {
            "title": "Join type",
            "enum": [
              "left",
              "inner"
            ],
            "type": "string",
            "description": "Left = keep every row of the first source. Inner = only rows found in both.",
            "default": "left"
          },
          "joinPrefix": {
            "title": "Prefix for joined fields",
            "type": "string",
            "description": "Optional, e.g. crm_ to tell joined fields apart."
          },
          "addSourceField": {
            "title": "Add _source field",
            "type": "boolean",
            "description": "Each row gets the dataset ID / file URL it came from (append mode).",
            "default": false
          },
          "selectFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Optional. Dot notation for nested fields (address.city). Order is kept in the output.",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "JSON map old name -> new name, e.g. {\"Email Address\": \"email\", \"company.name\": \"company\"}. Applied before selecting."
          },
          "dropFields": {
            "title": "Remove these fields",
            "type": "array",
            "description": "Optional.",
            "items": {
              "type": "string"
            }
          },
          "trimText": {
            "title": "Trim and collapse spaces in text",
            "type": "boolean",
            "description": "Removes leading/trailing spaces and double spaces in every top-level text field.",
            "default": true
          },
          "normalizeEmails": {
            "title": "Email fields to normalize",
            "type": "array",
            "description": "Lower-case, trimmed, \"Name <email>\" and mailto: cleaned.",
            "items": {
              "type": "string"
            }
          },
          "normalizePhones": {
            "title": "Phone fields to normalize (E.164)",
            "type": "array",
            "description": "Converted to +CountryNumber (e.g. +12025550143) with libphonenumber.",
            "items": {
              "type": "string"
            }
          },
          "phoneCountry": {
            "title": "Default phone country",
            "type": "string",
            "description": "Two-letter code for numbers without +country (US, GB, AR, BR, ES...)."
          },
          "normalizeUrls": {
            "title": "URL fields to normalize",
            "type": "array",
            "description": "Adds https://, lower-cases the host, removes tracking parameters (utm_*, gclid, fbclid...), fragments and trailing slashes.",
            "items": {
              "type": "string"
            }
          },
          "stripWww": {
            "title": "Remove www. from URLs",
            "type": "boolean",
            "description": "Useful to dedupe websites.",
            "default": false
          },
          "lowercaseFields": {
            "title": "Lower-case these fields",
            "type": "array",
            "description": "Optional.",
            "items": {
              "type": "string"
            }
          },
          "invalidValues": {
            "title": "Invalid emails / phones / URLs",
            "enum": [
              "keep",
              "empty",
              "dropRow"
            ],
            "type": "string",
            "description": "Keep the original value, empty it, or remove the row.",
            "default": "keep"
          },
          "flagInvalid": {
            "title": "Flag invalid values",
            "type": "boolean",
            "description": "Adds _invalidFields with the names of the fields that could not be normalized.",
            "default": true
          },
          "filters": {
            "title": "Filters",
            "type": "array",
            "description": "JSON list of conditions, e.g. [{\"field\": \"country\", \"op\": \"eq\", \"value\": \"US\"}, {\"field\": \"employees\", \"op\": \"gte\", \"value\": 10}]. Operators: eq, neq, contains, notContains, startsWith, endsWith, empty, notEmpty, gt, gte, lt, lte, in (comma list), regex. Text comparisons ignore case."
          },
          "filterMode": {
            "title": "Filter mode",
            "enum": [
              "all",
              "any"
            ],
            "type": "string",
            "description": "All conditions must match, or any of them.",
            "default": "all"
          },
          "dedupeFields": {
            "title": "Deduplicate by fields",
            "type": "array",
            "description": "Rows with the same values in these fields are duplicates (after normalization), e.g. email, or domain + country.",
            "items": {
              "type": "string"
            }
          },
          "dedupeKeep": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last",
              "mostComplete",
              "merge"
            ],
            "type": "string",
            "description": "Merge = keep the first row and fill its empty fields from the duplicates.",
            "default": "first"
          },
          "dedupeCaseSensitive": {
            "title": "Case-sensitive dedupe",
            "type": "boolean",
            "description": "Off = Apple and apple are the same value.",
            "default": false
          },
          "sortBy": {
            "title": "Sort by field",
            "type": "string",
            "description": "Optional. Numbers and text are sorted naturally."
          },
          "sortDesc": {
            "title": "Descending",
            "type": "boolean",
            "description": "Largest / latest first.",
            "default": false
          },
          "diffDatasetId": {
            "title": "Compare with a previous dataset",
            "type": "string",
            "description": "Dataset ID of an earlier run (e.g. yesterday's scrape). Each row gets _diff = added / changed / removed / unchanged, with the changed fields and their previous values."
          },
          "diffFileUrl": {
            "title": "...or a previous file URL",
            "type": "string",
            "description": "CSV / JSON / JSONL / XLSX of the previous version."
          },
          "diffKeys": {
            "title": "Diff key fields",
            "type": "array",
            "description": "What identifies the same record in both versions, e.g. url, id or sku. Defaults to the dedupe fields.",
            "items": {
              "type": "string"
            }
          },
          "diffIgnoreFields": {
            "title": "Ignore these fields when comparing",
            "type": "array",
            "description": "e.g. scrapedAt, timestamps or rankings that always change.",
            "items": {
              "type": "string"
            }
          },
          "diffOutput": {
            "title": "Diff output",
            "enum": [
              "changes",
              "added",
              "removed",
              "all"
            ],
            "type": "string",
            "description": "Which rows to output.",
            "default": "changes"
          },
          "outputDataset": {
            "title": "Save rows to the dataset",
            "type": "boolean",
            "description": "Off = only the export files.",
            "default": true
          },
          "outputFormats": {
            "title": "Export files",
            "type": "array",
            "description": "Files saved in the run's key-value store, with download links in RUN_SUMMARY and the Output tab. Nested fields are flattened with dots for XLSX and CSV.",
            "items": {
              "type": "string",
              "enum": [
                "xlsx",
                "csv",
                "jsonl",
                "json"
              ],
              "enumTitles": [
                "Excel (XLSX)",
                "CSV",
                "JSON Lines",
                "JSON"
              ]
            },
            "default": [
              "xlsx"
            ]
          },
          "fileName": {
            "title": "File name",
            "type": "string",
            "description": "Base name of the export files.",
            "default": "dataset"
          },
          "csvDelimiter": {
            "title": "CSV delimiter",
            "enum": [
              ",",
              ";",
              "tab"
            ],
            "type": "string",
            "description": "Semicolon is handy for Excel in many European / Latin American locales.",
            "default": ","
          },
          "arraysInFiles": {
            "title": "Lists in XLSX / CSV",
            "enum": [
              "join",
              "json"
            ],
            "type": "string",
            "description": "How list fields are written in flat files.",
            "default": "join"
          },
          "inferTypes": {
            "title": "Detect numbers and booleans in CSV",
            "type": "boolean",
            "description": "\"42\" becomes 42 and \"true\" becomes true (values with leading zeros stay text).",
            "default": true
          },
          "sheetName": {
            "title": "XLSX sheet to read",
            "type": "string",
            "description": "Optional; default is the first sheet."
          },
          "maxRows": {
            "title": "Max rows to read",
            "minimum": 1,
            "maximum": 2000000,
            "type": "integer",
            "description": "Upper limit of rows read from the sources (up to 2,000,000; large runs need more memory). Your max charge per run is respected too.",
            "default": 500000
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}