{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Filter & Transform - Dedupe, Clean, Export CSV",
    "description": "No-code filter, dedupe and transform for Apify datasets, CSV, XLSX and JSON files: rules (equals, contains, regex, ranges, dates, AND/OR), dedupe by fields, only-new-since-last-run, rename/select/drop, flatten, cast, sort, limit. Output to dataset plus CSV/XLSX/JSON export. Pay per row.",
    "version": "0.1",
    "x-build-id": "jHrYNfriKJnJ47wMv"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/gazidev~dataset-filter-transform/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-gazidev-dataset-filter-transform",
        "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/gazidev~dataset-filter-transform/runs": {
      "post": {
        "operationId": "runs-sync-gazidev-dataset-filter-transform",
        "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/gazidev~dataset-filter-transform/run-sync": {
      "post": {
        "operationId": "run-sync-gazidev-dataset-filter-transform",
        "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",
            "type": "array",
            "description": "One or more Apify dataset IDs (or 'username~dataset-name'), e.g. the output of a scraper run. Several datasets are processed one after another and merged into one output. In an integration / webhook use {{resource.defaultDatasetId}}."
          },
          "fileUrls": {
            "title": "File URLs (CSV, XLSX, JSON)",
            "type": "array",
            "description": "Public URLs of CSV, TSV, XLSX, XLS, ODS, JSON or JSON Lines files. Google Sheets ('Anyone with the link'), Google Drive, Dropbox, OneDrive and GitHub links are converted to direct downloads. The format is detected from the file content.",
            "items": {
              "type": "string"
            }
          },
          "items": {
            "title": "Or paste JSON items",
            "type": "array",
            "description": "Optional: a JSON array of objects to process directly (handy for quick tests and AI agents)."
          },
          "sheets": {
            "title": "Sheets (XLSX / ODS)",
            "type": "array",
            "description": "Sheet names or 1-based numbers to read from workbooks. Empty = all visible sheets.",
            "items": {
              "type": "string"
            }
          },
          "maxRowsToRead": {
            "title": "Max rows to read",
            "minimum": 0,
            "type": "integer",
            "description": "Stop reading after this many source rows in total (0 = read everything). Useful for previews.",
            "default": 0
          },
          "filters": {
            "title": "Filter rules",
            "type": "array",
            "description": "Keep only rows matching these rules. Each rule: {\"field\": \"price\", \"op\": \"between\", \"value\": [10, 50]}. Operators: equals, notEquals, contains, notContains, startsWith, endsWith, regex, notRegex, gt, gte, lt, lte, between, notBetween, in, notIn, exists, notExists, empty, notEmpty, before, after (dates, also \"now-7d\" / \"30 days ago\"), lengthGt, lengthLt, isTrue, isFalse. Text matching is case-insensitive unless \"caseSensitive\": true. Nest groups with {\"any\": [rules]} (OR) or {\"all\": [rules]} (AND), negate with {\"not\": rule}. Fields support dot paths (address.city, images.0.url)."
          },
          "filterLogic": {
            "title": "Combine rules with",
            "enum": [
              "and",
              "or"
            ],
            "type": "string",
            "description": "AND = a row must match every rule. OR = matching any rule is enough.",
            "default": "and"
          },
          "dedupeFields": {
            "title": "Remove duplicates by fields",
            "type": "array",
            "description": "Keep only the first row for each combination of these fields (e.g. 'url', or 'name' + 'city'). Rows where all of these fields are empty are never treated as duplicates. Works across all input sources.",
            "items": {
              "type": "string"
            }
          },
          "dedupeWholeRow": {
            "title": "Remove exact duplicate rows",
            "type": "boolean",
            "description": "When no dedupe fields are given: drop rows that are identical in every field.",
            "default": false
          },
          "dedupeIgnoreCase": {
            "title": "Ignore case and spaces when deduplicating",
            "type": "boolean",
            "description": "'ACME Inc ' and 'acme inc' count as the same value.",
            "default": true
          },
          "onlyNewItems": {
            "title": "Only new items since last run",
            "type": "boolean",
            "description": "Remember the dedupe key (or the whole row) of every delivered row in a named key-value store and skip rows already delivered in earlier runs. Ideal for scheduled scraper runs: you only get new listings / jobs / products.",
            "default": false
          },
          "stateStoreName": {
            "title": "State store name (only new items)",
            "type": "string",
            "description": "Named key-value store that holds the remembered keys. Use a different name per pipeline.",
            "default": "dataset-filter-transform-state"
          },
          "flattenNested": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "Turn {\"address\": {\"city\": \"Paris\"}} into {\"address.city\": \"Paris\"}. Applied first, so rules and fields can use the flat names.",
            "default": false
          },
          "flattenArrays": {
            "title": "Arrays when flattening",
            "enum": [
              "keep",
              "join",
              "index"
            ],
            "type": "string",
            "description": "Keep arrays as they are, join simple arrays into 'a, b, c' text, or expand them to indexed columns (images.0, images.1, ...).",
            "default": "keep"
          },
          "flattenSeparator": {
            "title": "Flatten separator",
            "type": "string",
            "description": "Separator used between nested key names.",
            "default": "."
          },
          "trimText": {
            "title": "Trim whitespace",
            "type": "boolean",
            "description": "Remove leading / trailing spaces from every text value (also nested).",
            "default": true
          },
          "collapseWhitespace": {
            "title": "Collapse inner whitespace",
            "type": "boolean",
            "description": "Replace runs of spaces, tabs and line breaks inside text with a single space.",
            "default": false
          },
          "stripHtml": {
            "title": "Strip HTML tags",
            "type": "boolean",
            "description": "Remove HTML tags and decode entities (&amp; -> &) in text values.",
            "default": false
          },
          "emptyStringsToNull": {
            "title": "Empty text to null",
            "type": "boolean",
            "description": "Turn empty strings into null.",
            "default": false
          },
          "textCase": {
            "title": "Change text case",
            "type": "object",
            "description": "Field -> lower | upper | title | capitalize | slug, e.g. {\"email\": \"lower\", \"name\": \"title\"}."
          },
          "castFields": {
            "title": "Convert types",
            "type": "object",
            "description": "Field -> string | number | integer | boolean | date | datetime | timestamp | array | json, e.g. {\"price\": \"number\", \"postedAt\": \"date\"}. Numbers like '$1,299.00' and '15%' are understood. Runs before the filter."
          },
          "castFailure": {
            "title": "When a value cannot be converted",
            "enum": [
              "null",
              "keep",
              "dropRow"
            ],
            "type": "string",
            "description": "Set it to null, keep the original value, or drop the whole row.",
            "default": "null"
          },
          "addFields": {
            "title": "Add / compute fields",
            "type": "object",
            "description": "New field -> template with {field} placeholders, e.g. {\"label\": \"{title} ({price} {currency})\", \"source\": \"google-maps\"}. A template that is just \"{field}\" copies the value with its type."
          },
          "sortBy": {
            "title": "Sort by",
            "type": "array",
            "description": "Fields to sort by, each optionally followed by 'desc', e.g. 'rating desc', 'name'. Numbers and dates sort naturally; empty values go last.",
            "items": {
              "type": "string"
            }
          },
          "offset": {
            "title": "Skip first N rows",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many kept rows (after sorting) before output.",
            "default": 0
          },
          "limit": {
            "title": "Max output rows",
            "minimum": 0,
            "type": "integer",
            "description": "Output at most this many rows (0 = no limit). Without sorting, reading stops as soon as the limit is reached.",
            "default": 0
          },
          "selectFields": {
            "title": "Keep only these fields",
            "type": "array",
            "description": "Output only these fields, in this order (dot paths allowed, e.g. 'address.city'). Empty = keep all.",
            "items": {
              "type": "string"
            }
          },
          "dropFields": {
            "title": "Remove fields",
            "type": "array",
            "description": "Fields to remove from the output (dot paths allowed).",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "Old name -> new name, e.g. {\"body_mass_g\": \"bodyMassGrams\"}. Applied last (filters, dedupe and sort use the original names)."
          },
          "removeEmptyFields": {
            "title": "Remove empty fields",
            "type": "boolean",
            "description": "Drop fields whose value is null, empty text, [] or {} from each row.",
            "default": false
          },
          "addSourceField": {
            "title": "Add _source field",
            "type": "boolean",
            "description": "Add the source dataset ID / file name (and _sheet for workbooks) to every row.",
            "default": false
          },
          "outputToDataset": {
            "title": "Save rows to dataset",
            "type": "boolean",
            "description": "Write the result rows to this run's dataset (download as JSON, CSV, Excel, or use via API / integrations).",
            "default": true
          },
          "exportFormat": {
            "title": "Also export a file",
            "enum": [
              "none",
              "csv",
              "xlsx",
              "json",
              "jsonl"
            ],
            "type": "string",
            "description": "Save the result as one file in the key-value store (link in the OUTPUT record). CSV and XLSX flatten nested fields automatically.",
            "default": "none"
          },
          "exportFileName": {
            "title": "Export file name",
            "type": "string",
            "description": "Base name of the export file (extension is added).",
            "default": "filtered-data"
          },
          "splitByField": {
            "title": "Split export by field",
            "type": "string",
            "description": "One export file per distinct value of this field (max 200, the rest goes to '-other'). For XLSX: one sheet per value in a single workbook."
          },
          "maxFileSizeMb": {
            "title": "Max input file size (MB)",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Larger input files are skipped (not charged).",
            "default": 500
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}