{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Toolkit: Dedup, Merge, Diff, Flatten",
    "description": "Remove duplicates, merge datasets, get new, changed and removed rows since the last run, or flatten nested data for spreadsheets. Streams millions of rows in 1 GB, works with limited permissions, integrations and AI agents, and never fails a run over empty data.",
    "version": "1.0",
    "x-build-id": "Uy1BTEvzLxPGYqVHh"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/rivetfinch~dataset-toolkit/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-rivetfinch-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/rivetfinch~dataset-toolkit/runs": {
      "post": {
        "operationId": "runs-sync-rivetfinch-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/rivetfinch~dataset-toolkit/run-sync": {
      "post": {
        "operationId": "run-sync-rivetfinch-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": {
          "operation": {
            "title": "Operation",
            "enum": [
              "dedup",
              "merge",
              "diff",
              "flatten"
            ],
            "type": "string",
            "description": "Dedup removes duplicate rows. Merge joins datasets into one (and removes duplicates if you set Key fields). Diff compares with a base dataset or with the previous run and labels rows new, changed or removed. Flatten turns nested objects into plain columns for spreadsheets.",
            "default": "dedup"
          },
          "datasets": {
            "title": "Datasets",
            "type": "array",
            "description": "The datasets to process, read in this order. Pick them from your account. In the API or from an AI agent, pass dataset IDs here, for example [\"aBcD1234eFgH5678i\"]. With a completely empty input the run shows a free built-in sample."
          },
          "keyFields": {
            "title": "Key fields",
            "type": "array",
            "description": "Fields that say two rows are the same record, for example url or email. Several fields are combined (sku + store). Dot paths reach nested fields (seller.id). Empty: dedup compares whole rows; diff matches whole rows. Not the columns to output: that is Pick fields.",
            "items": {
              "type": "string"
            }
          },
          "ignoreFields": {
            "title": "Ignore fields",
            "type": "array",
            "description": "Fields left out when whole rows are compared: in diff, and in dedup without key fields. Use it for values that change on every scrape, such as scrapedAt or a position number. Dot paths work.",
            "items": {
              "type": "string"
            }
          },
          "caseInsensitive": {
            "title": "Ignore upper and lower case in keys",
            "type": "boolean",
            "description": "Treat Example.com and example.com as the same key.",
            "default": false
          },
          "trimWhitespace": {
            "title": "Ignore extra spaces in keys",
            "type": "boolean",
            "description": "Trim spaces at the ends of key values and collapse runs of spaces inside them before comparing.",
            "default": true
          },
          "keep": {
            "title": "Which duplicate to keep",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "First keeps the earliest row (datasets are read in the order listed). Last keeps the latest one, which needs a second read of the data.",
            "default": "first"
          },
          "outputDuplicatesOnly": {
            "title": "Output duplicates only",
            "type": "boolean",
            "description": "Output the rows that dedup would remove, instead of the unique rows. Handy for checking what counts as a duplicate.",
            "default": false
          },
          "addSourceDatasetId": {
            "title": "Add source dataset column",
            "type": "boolean",
            "description": "Add _sourceDatasetId to every row, saying which dataset it came from.",
            "default": false
          },
          "baseDataset": {
            "title": "Base dataset (the old version)",
            "type": "string",
            "description": "Diff only. The older dataset to compare against; Datasets above hold the new version. Leave empty to compare with the previous run of this Actor that used the same State name."
          },
          "stateName": {
            "title": "State name (diff against the previous run)",
            "pattern": "^[a-zA-Z0-9-]{1,40}$",
            "type": "string",
            "description": "Needed for diff without a base dataset (a saved task gets its own state automatically). Each run remembers its rows under this name and the next run is compared with them, so a scheduled pipeline gets only new, changed and removed rows. One name per pipeline. Letters, digits and dashes."
          },
          "compareFields": {
            "title": "Compare fields",
            "type": "array",
            "description": "Diff only. Count a row as changed only when one of these fields differs, for example price and stock. Empty compares every field except Ignore fields.",
            "items": {
              "type": "string"
            }
          },
          "includeUnchanged": {
            "title": "Include unchanged rows",
            "type": "boolean",
            "description": "Diff only. Also output rows that did not change, labelled unchanged, to get the full current list with labels.",
            "default": false
          },
          "reportChangedFields": {
            "title": "Name the changed fields",
            "type": "boolean",
            "description": "Diff only. Fill _changedFields with the names of the fields that changed. Turning it off saves memory on very wide rows; changed rows then carry null there.",
            "default": true
          },
          "allowMassRemoval": {
            "title": "Allow mass removal",
            "type": "boolean",
            "description": "Diff against the previous run only. By default, when the input is empty or more than half of the remembered rows are missing, nothing is reported as removed and the state is kept, because that usually means a broken scrape. Turn on when the rows really are gone.",
            "default": false
          },
          "separator": {
            "title": "Column separator",
            "type": "string",
            "description": "Flatten only. Joins nested names into one column name: brand.name with a dot, brand_name with an underscore.",
            "default": "."
          },
          "arrays": {
            "title": "Lists",
            "enum": [
              "index",
              "join",
              "json"
            ],
            "type": "string",
            "description": "Flatten only. Index gives one column per element (tags.0, tags.1). Join puts a list of plain values into one text cell (running, trail); lists of objects stay indexed. JSON keeps the list as JSON text in one cell.",
            "default": "index"
          },
          "arrayJoiner": {
            "title": "Join lists with",
            "type": "string",
            "description": "Flatten only, with Lists set to join. Text placed between the values.",
            "default": ", "
          },
          "maxDepth": {
            "title": "Max depth",
            "minimum": 0,
            "type": "integer",
            "description": "Flatten only. How many levels to open. Deeper objects stay as JSON text in one cell. 0 means no limit.",
            "default": 0
          },
          "maxArrayItems": {
            "title": "Keep only the first N list elements",
            "minimum": 0,
            "type": "integer",
            "description": "Flatten only. Cut every list to its first N elements before flattening, so 50 images don't become 50 columns. 0 keeps all.",
            "default": 0
          },
          "pickFields": {
            "title": "Pick fields (columns to output)",
            "type": "array",
            "description": "Output only these columns, in this order. A dot path such as address.city becomes a column named address.city. Missing values come out empty. The _change, _changedFields and _sourceDatasetId columns are always kept. Empty outputs every column.",
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Omit fields",
            "type": "array",
            "description": "Remove these columns from the output. Dot paths remove nested fields (seller.phone).",
            "items": {
              "type": "string"
            }
          },
          "renameFields": {
            "title": "Rename fields",
            "type": "object",
            "description": "Old column name to new name, for example {\"title\": \"name\", \"address.city\": \"city\"}."
          },
          "filterField": {
            "title": "Filter field",
            "type": "string",
            "description": "Keep or drop rows by the value of this field (dot paths work; _change works in diff). With no pattern, a row matches when the field has any value."
          },
          "filterPattern": {
            "title": "Filter pattern",
            "type": "string",
            "description": "Text or regular expression searched in the filter field, ignoring case. remote matches Remote job; ^new$|^changed$ matches exactly those. Lists and objects are searched as JSON text."
          },
          "filterMode": {
            "title": "Filter mode",
            "enum": [
              "keep",
              "drop"
            ],
            "type": "string",
            "description": "Keep only matching rows, or drop matching rows.",
            "default": "keep"
          },
          "offset": {
            "title": "Skip first rows",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many output rows (after the filter). Skipped rows are not charged.",
            "default": 0
          },
          "limit": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many output rows. 0 means no limit. Your maximum cost per run is also respected.",
            "default": 0
          },
          "datasetId": {
            "title": "Dataset ID (for integrations)",
            "type": "string",
            "description": "One more dataset, typed as an ID or name. For an integration that runs after another Actor, put {{resource.defaultDatasetId}} here; this field gives the run read access to that dataset."
          },
          "datasetIds": {
            "title": "Dataset or run IDs as text",
            "type": "array",
            "description": "Dataset IDs, run IDs or Apify dataset links typed as text. This Actor runs with limited permissions, so Apify may refuse these reads; the run then names each one and tells you to move it to Datasets, which always works.",
            "items": {
              "type": "string"
            }
          },
          "payload": {
            "title": "Integration payload",
            "type": "object",
            "description": "Filled in by Apify when this Actor runs as an integration. When no dataset is given anywhere else, the triggering run's dataset is tried from here."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}