{
  "openapi": "3.0.1",
  "info": {
    "title": "Survey Data Cleaner (CSV, SPSS .sav, Qualtrics)",
    "description": "Cleans a survey export (CSV, SPSS .sav or Qualtrics CSV) with fixed, documented rules and returns the cleaned file, a reconstructed codebook, and a row-level report of every change. Speeders, straight-liners and out-of-range answers are flagged, never deleted.",
    "version": "0.1",
    "x-build-id": "r3zxUmPj7LCL5iGeU"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/madrasco~survey-data-cleaner/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-madrasco-survey-data-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/madrasco~survey-data-cleaner/runs": {
      "post": {
        "operationId": "runs-sync-madrasco-survey-data-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/madrasco~survey-data-cleaner/run-sync": {
      "post": {
        "operationId": "run-sync-madrasco-survey-data-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": {
          "fileUrl": {
            "title": "File URL",
            "type": "string",
            "description": "Direct download link to a .csv, .tsv or SPSS .sav survey export (Qualtrics CSV/TSV exports are detected automatically). Must work without a login. Leave empty if you pick a key-value store below. If both are empty, a small built-in synthetic Qualtrics demo file is cleaned (free) so you can see the output."
          },
          "keyValueStoreId": {
            "title": "Key-value store with your uploaded file",
            "type": "string",
            "description": "Or pick a key-value store in your Apify account where you uploaded the file (Storage tab). The first .csv, .tsv, .txt or .sav record is used unless you give its key below."
          },
          "fileKey": {
            "title": "Record key",
            "type": "string",
            "description": "Optional: the key of the file in the key-value store above."
          },
          "format": {
            "title": "File format",
            "enum": [
              "auto",
              "csv",
              "sav"
            ],
            "type": "string",
            "description": "Normally detected from the file itself.",
            "default": "auto"
          },
          "idColumn": {
            "title": "Respondent ID column",
            "type": "string",
            "description": "Column that identifies a respondent, used to remove repeated submissions. If empty, a column named ResponseId, respondent_id, id, caseid or similar is used when present."
          },
          "dedupeById": {
            "title": "Remove repeated respondent IDs",
            "type": "boolean",
            "description": "Keep the first row for each respondent ID and remove later rows with the same ID (each removal is in the change report). Without an ID column, identical rows are flagged instead.",
            "default": true
          },
          "trimWhitespace": {
            "title": "Trim spaces and invisible characters",
            "type": "boolean",
            "description": "Trims leading/trailing spaces, collapses repeated and non-breaking spaces and removes invisible characters in every cell (line breaks inside answers are kept).",
            "default": true
          },
          "standardizeMissing": {
            "title": "Standardize missing-value codes",
            "type": "boolean",
            "description": "Replace missing-value codes (the list below, and values declared user-missing in an SPSS file) with empty cells. The codebook counts which codes were found in each column.",
            "default": true
          },
          "missingCodes": {
            "title": "Missing-value codes",
            "type": "array",
            "description": "Whole-cell values treated as missing (compared without regard to case). Default: NA, N/A, #N/A, NULL, None, nan, NaN, ., -, --, -99, -999, -9999. Remove -99 etc. if they are real answers in your data.",
            "items": {
              "type": "string"
            }
          },
          "normalizeNumbers": {
            "title": "Write numbers in plain form",
            "type": "boolean",
            "description": "In numeric columns: 1,234 becomes 1234, 3.0 becomes 3, +5 becomes 5. Text in a numeric column is flagged, not changed.",
            "default": true
          },
          "normalizeDates": {
            "title": "Write dates as YYYY-MM-DD",
            "type": "boolean",
            "description": "Rewrites unambiguous YYYY/MM/DD and YYYY.MM.DD dates. Day/month orders that could be read both ways are left alone.",
            "default": true
          },
          "unifyCategoryCase": {
            "title": "Unify answer spelling variants",
            "type": "boolean",
            "description": "In columns with few distinct answers (30 or fewer), answers that differ only by case or spacing ('male', 'MALE', ' Male') are rewritten to the most common spelling.",
            "default": true
          },
          "ranges": {
            "title": "Allowed ranges",
            "type": "object",
            "description": "Values outside these ranges are flagged. Keys are column names or patterns with * (e.g. \"Q3_*\"). Columns with SPSS value labels are also checked against their labelled codes."
          },
          "durationColumn": {
            "title": "Duration column (seconds)",
            "type": "string",
            "description": "Column with completion time in seconds, for the speeder check. If empty, Qualtrics 'Duration (in seconds)' or a column named duration is used when present."
          },
          "speederFraction": {
            "title": "Speeder threshold (fraction of median)",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Respondents faster than this fraction of the median duration are flagged. 0 turns the check off.",
            "default": 0.33
          },
          "straightlineMinItems": {
            "title": "Straight-lining: minimum grid items",
            "minimum": 2,
            "maximum": 100,
            "type": "integer",
            "description": "Question grids are columns named like Q5_1, Q5_2, ... A respondent giving the same answer to at least this many items of a grid is flagged.",
            "default": 5
          },
          "addFlagColumn": {
            "title": "Add qc_flags column",
            "type": "boolean",
            "description": "Adds a qc_flags column to the cleaned file listing each row's flags.",
            "default": true
          },
          "maxDatasetItems": {
            "title": "Maximum dataset items",
            "minimum": 0,
            "maximum": 100000,
            "type": "integer",
            "description": "Changes and flags written to the dataset (the CSV reports always contain all of them).",
            "default": 5000
          },
          "maxFileMb": {
            "title": "Maximum file size (MB)",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Larger files are refused. Raise memory for big files.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}