{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Cleaner: dedupe, normalize phones, emails and URLs",
    "description": "Clean scraper, CSV or JSON rows: remove duplicates (exact, loose, fuzzy), normalize phones to E.164, emails, URLs, domains, dates and countries, split names, drop empty columns. Reads a dataset ID, file link or pasted rows. No AI. $0.0003 per row written.",
    "version": "0.1",
    "x-build-id": "gpqEExkZjLpCnEYZA"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/opstoolkit~dataset-cleaner/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-opstoolkit-dataset-cleaner",
        "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/opstoolkit~dataset-cleaner/runs": {
      "post": {
        "operationId": "runs-sync-opstoolkit-dataset-cleaner",
        "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/opstoolkit~dataset-cleaner/run-sync": {
      "post": {
        "operationId": "run-sync-opstoolkit-dataset-cleaner",
        "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": {
          "rows": {
            "title": "Rows",
            "type": "array",
            "description": "Rows to clean, as a JSON list of objects. Example: [{\"company\": \"ACME inc\", \"phone\": \"03 123 456\", \"email\": \"Info@Acme.com\"}]. Leave empty when you use datasetIds or fileUrls. Inline rows are read first, then datasets, then files, and all are cleaned as one list. The prefilled sample is messy on purpose: mixed phone formats, duplicate companies, tracking parameters in URLs and country names in different forms."
          },
          "datasetIds": {
            "title": "Apify dataset IDs",
            "type": "array",
            "description": "IDs of Apify datasets your account can read, one per item. Example: [\"aBcDeFgHiJkLmNoPq\"]. Typical use: the default dataset of a finished run of Local Business Leads or Company Contact Finder, found in the run's Storage tab. Several IDs are merged into one list, and duplicates across them are removed.",
            "items": {
              "type": "string"
            }
          },
          "fileUrls": {
            "title": "Links to CSV, JSON or JSONL files",
            "type": "array",
            "description": "Public links, one per item. Example: [\"https://example.com/leads.csv\"]. The first row of a CSV is the header. Up to 60 MB per file. Excel files are not read, save them as CSV. Links to private network addresses are refused.",
            "items": {
              "type": "string"
            }
          },
          "maxRows": {
            "title": "Max rows to read",
            "minimum": 1,
            "maximum": 2000000,
            "type": "integer",
            "description": "Reading stops after this many rows in total. A whole number from 1 to 2,000,000. Rows are held in memory only when you keep the last or most complete duplicate, drop empty columns or write the CSV: about 1 GB of run memory covers 200,000 rows then. Default: 200000.",
            "default": 200000
          },
          "trimWhitespace": {
            "title": "Trim whitespace",
            "type": "boolean",
            "description": "When true, every text value is trimmed, repeated spaces are collapsed and non-breaking spaces become normal ones. Column names are trimmed too. Default: true.",
            "default": true
          },
          "placeholdersAsEmpty": {
            "title": "Treat placeholders as empty",
            "type": "boolean",
            "description": "When true, values that are only N/A, null, undefined, nan, none or a dash become empty (null), so they count as missing in duplicate checks and required columns. Default: true.",
            "default": true
          },
          "flattenObjects": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "When true, {\"address\": {\"city\": \"Beirut\"}} becomes a column called address.city. Lists are kept as lists. Do this before rules that need a flat column name. Default: false.",
            "default": false
          },
          "rules": {
            "title": "Rules",
            "type": "array",
            "description": "Cleaning rules, one per item, written as column: operation option=value. Operations: trim, collapse-spaces, lower, upper, title, strip-accents, strip-html, phone, email, url, domain, host, date, country, money, split-name, drop. Example: [\"phone: phone country=LB\", \"website: domain into=domain\", \"added: date dayfirst=yes\"]. Use * as the column for every column, commas to list several columns, into=newcolumn to keep the original, invalid=blank to empty unreadable values. Rules run in the order given.",
            "items": {
              "type": "string"
            }
          },
          "defaultCountry": {
            "title": "Default country for phone numbers",
            "type": "string",
            "description": "Two-letter ISO country code, for example LB, US or GB. Used to read phone numbers written without a + sign and to match phones when deduplicating. A rule can override it with country=XX. Leave empty if all numbers already start with + and a country code."
          },
          "dedupeBy": {
            "title": "Find duplicates by these columns",
            "type": "array",
            "description": "Column names that identify one record, as they are after your rules ran. Example: [\"phone\", \"email\"]. Leave empty to keep every row. Rows where all of these columns are empty are never treated as duplicates. Duplicates are dropped and not charged.",
            "items": {
              "type": "string"
            }
          },
          "dedupeMode": {
            "title": "How strict",
            "enum": [
              "exact",
              "loose",
              "fuzzy"
            ],
            "type": "string",
            "description": "exact: values must be identical after trimming, case counts. loose: ignores case, accents, punctuation, spacing, www, http, tracking parameters, phone formatting and company endings such as Inc or Ltd. fuzzy: loose, plus close spellings above fuzzyThreshold. Default: loose.",
            "default": "loose"
          },
          "dedupeMatch": {
            "title": "Match on",
            "enum": [
              "all",
              "any"
            ],
            "type": "string",
            "description": "all: every column in dedupeBy must match for two rows to be duplicates. any: one matching column is enough, for example the same phone or the same email, which is the usual choice for leads. Default: all.",
            "default": "all"
          },
          "fuzzyThreshold": {
            "title": "Fuzzy similarity (50 to 100)",
            "minimum": 50,
            "maximum": 100,
            "type": "integer",
            "description": "Only used when dedupeMode is fuzzy. A whole number from 50 to 100, higher is stricter. 90 catches typos and small wording changes. Only values that start with the same three letters are compared. Default: 90.",
            "default": 90
          },
          "keep": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last",
              "most-complete"
            ],
            "type": "string",
            "description": "first: the earliest row. last: the latest row. most-complete: the row with the most filled columns. Anything but first holds all rows in memory until the end. Default: first.",
            "default": "first"
          },
          "requiredFields": {
            "title": "Drop rows missing these columns",
            "type": "array",
            "description": "Column names, one per item. Example: [\"phone\"]. A row is dropped, and not charged, when any of these columns is empty after your rules ran. Combine with invalid=blank on a rule to drop rows with a bad phone or email. Leave empty to keep rows whatever they lack.",
            "items": {
              "type": "string"
            }
          },
          "dropEmptyColumns": {
            "title": "Drop columns that are empty in every row",
            "type": "boolean",
            "description": "When true, a column with no value in any row is left out of the output. Holds all rows in memory until the end. Default: false.",
            "default": false
          },
          "renameFields": {
            "title": "Rename columns",
            "type": "object",
            "description": "Object mapping old column name to new name. Example: {\"company\": \"Business name\"}. Applied last, after duplicates are found, so dedupeBy and rules use the old names."
          },
          "selectFields": {
            "title": "Keep only these columns, in this order",
            "type": "array",
            "description": "Column names to keep, in output order, one per item. Example: [\"businessName\", \"phone\", \"email\"]. Use the names after renaming. Leave empty to keep all columns. A name that does not exist gives an empty column.",
            "items": {
              "type": "string"
            }
          },
          "sourceColumn": {
            "title": "Source column name",
            "type": "string",
            "description": "Optional. A column name such as source. When set, each row gets a column with where it came from: inline, the dataset ID or the file link. Useful when you merge several sources. Leave empty to add no column."
          },
          "exportCsv": {
            "title": "Also write a CSV file",
            "type": "boolean",
            "description": "When true, the cleaned rows are also saved as cleaned.csv in the run's key-value store. Lists are joined with semicolons. Holds the written rows in memory. Default: false.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}