{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Explode & Unpivot: arrays to rows",
    "description": "Turn array fields into one row per element (explode), wide columns into name/value rows (unpivot) or back (pivot) for Apify datasets and JSON/CSV files. Works from the Console form. Empty input = free demo. $0.20 per 1,000 output rows.",
    "version": "0.1",
    "x-build-id": "KmoLZLdmqbgQoHAGd"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/ucchiii~dataset-explode-unpivot/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-ucchiii-dataset-explode-unpivot",
        "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/ucchiii~dataset-explode-unpivot/runs": {
      "post": {
        "operationId": "runs-sync-ucchiii-dataset-explode-unpivot",
        "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/ucchiii~dataset-explode-unpivot/run-sync": {
      "post": {
        "operationId": "run-sync-ucchiii-dataset-explode-unpivot",
        "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": [
              "explode",
              "unpivot",
              "pivot"
            ],
            "type": "string",
            "description": "What to do with the rows. Explode copies the parent fields onto one row per element of an array field. Unpivot (wide to long) keeps id columns and turns value columns into name/value rows. Pivot (long to wide) does the reverse. Default: explode.",
            "default": "explode"
          },
          "datasetIds": {
            "title": "Apify datasets",
            "type": "array",
            "description": "Datasets to reshape (the 'defaultDatasetId' of a finished run). You can paste a dataset URL from Apify Console too. Up to 20 datasets and files together; several sources are processed one after the other (pivot combines them). Leave this AND 'File URLs' empty to run a free demo on a built-in sample (not charged)."
          },
          "fileUrls": {
            "title": "File URLs",
            "type": "array",
            "description": "Public http(s) links to JSON, NDJSON, CSV or TSV files (up to 50 MB each). Links to internal networks are blocked. Clear this list and 'Apify datasets' to run the free demo.",
            "items": {
              "type": "string"
            }
          },
          "inputFormat": {
            "title": "File format",
            "enum": [
              "auto",
              "json",
              "ndjson",
              "csv",
              "tsv"
            ],
            "type": "string",
            "description": "Format of the files in 'File URLs'. 'auto' uses the file extension, content type and content. Ignored for datasets. Default: auto.",
            "default": "auto"
          },
          "recordsPath": {
            "title": "Records path (JSON files)",
            "type": "string",
            "description": "For a JSON file whose rows sit inside an object, the dot path to the array of rows, e.g. 'products' or 'data.items'. Empty = the file is an array, or the only array of objects in it is used."
          },
          "explodeFields": {
            "title": "Explode: array fields",
            "type": "array",
            "description": "Explode only. Dot paths of the array fields to turn into rows, such as 'reviews' or 'offers.items' (up to 50). Each element becomes a row with the parent fields copied; object elements get their keys flattened with the path as prefix (reviews.rating). A value that is not an array counts as one element.",
            "items": {
              "type": "string"
            }
          },
          "multiFieldMode": {
            "title": "Explode: several fields",
            "enum": [
              "zip",
              "cross"
            ],
            "type": "string",
            "description": "Explode only, when you list more than one array field. Zip pairs the elements by position (shorter arrays are padded with null). Cross makes every combination, which can multiply the rows quickly. Default: zip.",
            "default": "zip"
          },
          "indexColumn": {
            "title": "Explode: index column",
            "type": "string",
            "description": "Name of the column that holds the 0-based position of the element in its array. With 'cross' and several fields each field gets its own column, '_index_<field>'. Default: _index.",
            "default": "_index"
          },
          "keepEmpty": {
            "title": "Explode: keep rows with empty arrays",
            "type": "boolean",
            "description": "When an array is empty, null or missing, keep the parent as one row with null in the exploded column instead of dropping it. Default: on.",
            "default": true
          },
          "idColumns": {
            "title": "Unpivot / pivot: id columns",
            "type": "array",
            "description": "Unpivot: columns that stay on every output row. Pivot: columns that identify one output row (the same combination of values becomes one row). Nested names use the flatten separator (customer.id); a parent name keeps every column under it when unpivoting.",
            "items": {
              "type": "string"
            }
          },
          "valueColumns": {
            "title": "Unpivot: value columns",
            "type": "array",
            "description": "Unpivot only. Columns to turn into name/value rows, e.g. jan, feb, mar. Empty = every column that is not an id column.",
            "items": {
              "type": "string"
            }
          },
          "unpivotNameColumn": {
            "title": "Unpivot: name column",
            "type": "string",
            "description": "Unpivot only. Output column that holds the old column name (for example 'month'). Default: name.",
            "default": "name"
          },
          "unpivotValueColumn": {
            "title": "Unpivot: value column",
            "type": "string",
            "description": "Unpivot only. Output column that holds the value (for example 'sales'). Default: value.",
            "default": "value"
          },
          "unpivotDropEmpty": {
            "title": "Unpivot: drop empty values",
            "type": "boolean",
            "description": "Skip name/value rows whose value is null or an empty string. Turn off to keep them. Default: on.",
            "default": true
          },
          "pivotNameColumn": {
            "title": "Pivot: name column",
            "type": "string",
            "description": "Pivot only. The column whose values become the new column names (for example 'month'). Rows where it is empty are skipped and counted in the run summary."
          },
          "pivotValueColumn": {
            "title": "Pivot: value column",
            "type": "string",
            "description": "Pivot only. The column whose values fill the new columns (for example 'sales')."
          },
          "aggregation": {
            "title": "Pivot: duplicates",
            "enum": [
              "first",
              "last",
              "sum",
              "count",
              "list"
            ],
            "type": "string",
            "description": "Pivot only. What to put in a cell when several rows share the same id and name. 'sum' adds numbers and numeric text and skips other values; 'list' keeps every value as an array. Default: first.",
            "default": "first"
          },
          "flattenSeparator": {
            "title": "Flatten separator",
            "type": "string",
            "description": "Text that joins nested key names, e.g. '.' gives shop.city and '_' gives shop_city. Max 5 characters. Field paths you type are always split on dots. Default: '.'.",
            "default": "."
          },
          "maxOutputRows": {
            "title": "Max output rows",
            "minimum": 1,
            "maximum": 1000000,
            "type": "integer",
            "description": "Stop after this many output rows. Exploding can multiply rows, so this caps both the run time and the cost ($0.20 per 1,000 rows). When it stops early, 'truncated' is true in the run summary. Maximum 1,000,000. Default: 100,000.",
            "default": 100000
          },
          "exportCsv": {
            "title": "Also save a CSV file",
            "type": "boolean",
            "description": "Besides the dataset, save all output rows as one CSV file in the key-value store (a public download link is in the run summary). Nested values are written as JSON text. Default: off.",
            "default": false
          },
          "fileName": {
            "title": "CSV file name",
            "type": "string",
            "description": "File name without extension for the CSV (only letters, digits, dot, dash and underscore are kept). Empty = 'reshaped'."
          },
          "csvDelimiter": {
            "title": "CSV delimiter",
            "enum": [
              ",",
              ";",
              "tab",
              "|"
            ],
            "type": "string",
            "description": "Column separator of the CSV file. Default: comma.",
            "default": ","
          },
          "csvBom": {
            "title": "CSV: add UTF-8 BOM for Excel",
            "type": "boolean",
            "description": "Adds a byte-order mark so Excel opens non-English text (for example Japanese) correctly. Leave off for pandas and databases.",
            "default": false
          },
          "csvEscapeFormulas": {
            "title": "CSV: neutralize spreadsheet formulas",
            "type": "boolean",
            "description": "Prefix text cells that start with =, +, @ (or - followed by text) with an apostrophe so Excel never runs them as formulas.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}