{
  "openapi": "3.0.1",
  "info": {
    "title": "Tidy CSV: Trim, Dedupe and Sort",
    "description": "CSV clean-up: trim cells, snake_case headers, drop empty rows, remove duplicates on all columns or chosen key columns, and optionally sort. Output CSV or JSON with a summary. The cleaning code makes no network calls and does no scraping.",
    "version": "0.1",
    "x-build-id": "rDeOa1UnUi8wCvaNW"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/brightwater-tools~csv-cleaner-deduplicator/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-brightwater-tools-csv-cleaner-deduplicator",
        "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/brightwater-tools~csv-cleaner-deduplicator/runs": {
      "post": {
        "operationId": "runs-sync-brightwater-tools-csv-cleaner-deduplicator",
        "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/brightwater-tools~csv-cleaner-deduplicator/run-sync": {
      "post": {
        "operationId": "run-sync-brightwater-tools-csv-cleaner-deduplicator",
        "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",
        "required": [
          "csv_text"
        ],
        "properties": {
          "csv_text": {
            "title": "CSV text",
            "type": "string",
            "description": "The whole CSV document to clean. The first row must be the header. Nothing is fetched from a URL or read from a file. The size limit is max_input_bytes.",
            "default": "Part Name,Unit Cost (USD),Qty\n  Bolt M6 ,1.25, 10\nBolt M6,1.25,10\n,,\nNut M6,0.40,25\n"
          },
          "delimiter": {
            "title": "Delimiter",
            "minLength": 1,
            "maxLength": 1,
            "type": "string",
            "description": "One character that separates fields in the input, and is also used for CSV output. Use ',' for comma, ';' for semicolon or a tab character for tab-separated files.",
            "default": ","
          },
          "output_format": {
            "title": "Output format",
            "enum": [
              "csv",
              "json"
            ],
            "type": "string",
            "description": "'csv' writes the cleaned table as CSV. 'json' writes a JSON array with one object per row, keyed by the cleaned column names. Values stay as text in both formats.",
            "default": "csv"
          },
          "trim_cells": {
            "title": "Trim spaces around cells",
            "type": "boolean",
            "description": "Remove leading and trailing whitespace from every header and cell before the other steps run. Turn off to keep the spaces.",
            "default": true
          },
          "snake_case_headers": {
            "title": "Convert headers to snake_case",
            "type": "boolean",
            "description": "Rename headers to lower_case_with_underscores, for example 'Unit Cost (USD)' becomes 'unit_cost_usd'. A blank header becomes column_N, where N is its position. Two headers that end up with the same name are refused.",
            "default": true
          },
          "drop_empty_rows": {
            "title": "Drop empty rows",
            "type": "boolean",
            "description": "Remove rows in which every cell is blank. The number removed is reported in the summary.",
            "default": true
          },
          "dedupe": {
            "title": "Remove duplicate rows",
            "enum": [
              "off",
              "all_columns",
              "key_columns"
            ],
            "type": "string",
            "description": "'off' keeps every row. 'all_columns' removes a row when every cell matches an earlier row. 'key_columns' removes a row when the cells in key_columns match an earlier row. The first row of each group is kept.",
            "default": "all_columns"
          },
          "key_columns": {
            "title": "Key columns",
            "type": "string",
            "description": "Comma-separated column names used when 'Remove duplicate rows' is key_columns, for example 'part_name,supplier'. Names are matched after the snake_case step, or as written when that step is off. Ignored otherwise.",
            "default": ""
          },
          "sort_by": {
            "title": "Sort by column",
            "type": "string",
            "description": "One column name to sort the rows by, after duplicates are removed. Numbers sort by value, text sorts by character code, and blank cells always go last. Leave empty to keep the original order.",
            "default": ""
          },
          "sort_order": {
            "title": "Sort order",
            "enum": [
              "asc",
              "desc"
            ],
            "type": "string",
            "description": "'asc' sorts from smallest to largest, 'desc' from largest to smallest. Used only when 'Sort by column' is set.",
            "default": "asc"
          },
          "max_input_bytes": {
            "title": "Maximum input size (bytes)",
            "minimum": 1,
            "maximum": 5000000,
            "type": "integer",
            "description": "Input larger than this is refused with an error. The hard ceiling is 5,000,000 bytes.",
            "default": 1000000
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}