{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Sort: sort CSV, JSON & dataset rows",
    "description": "Sorts the rows of an Apify dataset or a CSV / JSON file by one or more columns: ascending or descending, as numbers, text or dates, natural order (item 2 before item 10), empty values first or last. Top-N, dedupe, CSV export. Empty input = free demo.",
    "version": "0.1",
    "x-build-id": "GwvwzOvBQa4PWMgEm"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/ucchiii~dataset-sort/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-ucchiii-dataset-sort",
        "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-sort/runs": {
      "post": {
        "operationId": "runs-sync-ucchiii-dataset-sort",
        "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-sort/run-sync": {
      "post": {
        "operationId": "run-sync-ucchiii-dataset-sort",
        "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 datasets",
            "type": "array",
            "description": "Datasets to sort (the 'defaultDatasetId' of a finished run). You can paste a dataset URL from Apify Console too. Several datasets and files are read in the order given and sorted together as one table. Up to 20 in total. 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 CSV, TSV, JSON or NDJSON files (up to 100 MB each; a JSON array up to 50 MB, use NDJSON for bigger files). The encoding (UTF-8, Shift JIS, Windows-1252) and the delimiter are detected. Links to internal networks are blocked.",
            "items": {
              "type": "string"
            }
          },
          "sortKeys": {
            "title": "Sort keys",
            "type": "array",
            "description": "The columns to sort by, most important first. Each entry is a column name, or an object with 'field' and any of: 'direction' ('asc' or 'desc'), 'type' ('auto', 'number', 'text', 'date'), 'ignoreCase' (true/false), 'natural' (true/false), 'nulls' ('first' or 'last'). Example: [\"country\", {\"field\": \"price\", \"direction\": \"desc\", \"type\": \"number\"}]. A name with a leading minus sorts descending (\"-price\"). Nested fields use dots (owner.name). Options you leave out take the defaults below. Required unless you run the demo."
          },
          "direction": {
            "title": "Default direction",
            "enum": [
              "asc",
              "desc"
            ],
            "type": "string",
            "description": "Direction for every sort key that does not set its own. Default: ascending.",
            "default": "asc"
          },
          "valueType": {
            "title": "Default value type",
            "enum": [
              "auto",
              "number",
              "text",
              "date"
            ],
            "type": "string",
            "description": "How the values of a column are compared. 'auto' looks at the whole column: all numbers (also '1,200', '$5', '12%') = number; all dates (2026-03-04, 2026-03-04T10:00:00Z, 4 Mar 2026) = date; anything else = text. Set it yourself when a column mixes kinds, for example ZIP codes that should stay text. Values that cannot be read as the chosen type are treated as empty. Default: auto.",
            "default": "auto"
          },
          "ignoreCase": {
            "title": "Ignore case",
            "type": "boolean",
            "description": "Text sort: 'apple' and 'Banana' are compared without regard to case. Turn off for a strict character order where all capitals come before all lower-case letters. Default: on.",
            "default": true
          },
          "naturalSort": {
            "title": "Natural order",
            "type": "boolean",
            "description": "Text sort: digits inside text are compared as numbers, so 'item 2' comes before 'item 10' and 'v1.9' before 'v1.10'. Off = plain character order ('item 10' before 'item 2'). Default: off.",
            "default": false
          },
          "nulls": {
            "title": "Empty values",
            "enum": [
              "last",
              "first"
            ],
            "type": "string",
            "description": "Where rows with an empty value (missing, null, blank or not readable as the chosen type) go. This is independent of the direction: 'at the end' means the end of the result even when sorting descending. Default: at the end.",
            "default": "last"
          },
          "dateOrder": {
            "title": "Day and month order in dates like 03/04/2026",
            "enum": [
              "auto",
              "mdy",
              "dmy"
            ],
            "type": "string",
            "description": "Dates written with slashes are ambiguous, so they are only read when you say which order you use. Dates like 2026-03-04, 2026/03/04, 04.03.2026 and 4 Mar 2026 are always understood. Default: not read.",
            "default": "auto"
          },
          "dedupeFields": {
            "title": "Dedupe columns",
            "type": "array",
            "description": "Column names. After sorting, a row whose values in these columns equal those of an earlier row is dropped, so one row per combination stays: the first in the sorted order. Sort so the row you want comes first (newest date first, lowest price first) and list the columns that identify a group, for example 'email'. Compared the way they are sorted: with 'Ignore case' on, 'A' and 'a' are the same; 1 and 1.0 are the same number; two empty values are equal. Empty list = keep every row.",
            "items": {
              "type": "string"
            }
          },
          "offset": {
            "title": "Skip the first rows",
            "minimum": 0,
            "type": "integer",
            "description": "Number of rows to leave out from the start of the sorted (and deduplicated) result. Use it with 'Top N rows' to get page 2, 3 ... Default: 0.",
            "default": 0
          },
          "limit": {
            "title": "Top N rows",
            "minimum": 0,
            "maximum": 1000000,
            "type": "integer",
            "description": "Return only this many rows from the sorted result, for example 10 for the ten highest prices. 0 = all rows. You are charged only for the rows returned. Default: 0 (all).",
            "default": 0
          },
          "outputCsv": {
            "title": "Also save a CSV file",
            "type": "boolean",
            "description": "Besides the dataset, save the sorted rows as one CSV file in the key-value store (record 'sorted.csv', UTF-8 with BOM so Excel opens it correctly). The file is built in memory, so it adds to the memory use of big runs. Nested values are written as JSON text. Default: off.",
            "default": false
          },
          "maxInputRows": {
            "title": "Max input rows",
            "minimum": 1,
            "maximum": 1000000,
            "type": "integer",
            "description": "Safety limit on the rows read across all sources. A sort needs every row, so if there are more rows than this the run stops without sorting or charging (it never sorts a partial read). Maximum and default: 1,000,000.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}