{
  "openapi": "3.0.1",
  "info": {
    "title": "DuckDB Helper – SQL over CSV, JSON, Parquet, Excel, SQLite",
    "description": "Run a DuckDB SQL query over remote or local input files (CSV, JSON/NDJSON, Parquet, Excel, Avro, SQLite, and more) and push the results to a dataset.",
    "version": "0.1",
    "x-build-id": "l4dp2RCQhTu8z733D"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/rl1987~duckdb-wrapper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-rl1987-duckdb-wrapper",
        "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/rl1987~duckdb-wrapper/runs": {
      "post": {
        "operationId": "runs-sync-rl1987-duckdb-wrapper",
        "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/rl1987~duckdb-wrapper/run-sync": {
      "post": {
        "operationId": "run-sync-rl1987-duckdb-wrapper",
        "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": [
          "sqlQuery",
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "free",
              "paid"
            ],
            "type": "string",
            "description": "Free: try out your SQL against literals or a URL read directly inside the query (e.g. `read_csv('https://...')`) — no charge, but `inputFiles`/`datasetId` below are disabled. Paid: load `inputFiles` and/or a chained `datasetId` — $0.01 per successful run, regardless of data size.",
            "default": "free"
          },
          "sqlQuery": {
            "title": "SQL query",
            "type": "string",
            "description": "SQL to run in DuckDB (DuckDB SQL syntax). In free mode, use literals, paste data into `inlineData` below and query its view, or read a URL directly with a DuckDB table function (read_csv, read_json, read_parquet, ...) — httpfs is preloaded so http(s):// URLs work inline. In paid mode, also reference the views defined in `inputFiles`/`datasetId` below by name.",
            "default": "SELECT * FROM data WHERE age >= 18"
          },
          "inlineData": {
            "title": "Paste data",
            "type": "string",
            "description": "Paste CSV/TSV/JSON/NDJSON text directly to test your query against real data — no URL, no download, works in free mode. Loaded as a view named by `inlineViewName` (default `data`) in the format set by `inlineFormat`."
          },
          "inlineFormat": {
            "title": "Pasted data format",
            "enum": [
              "csv",
              "tsv",
              "json",
              "ndjson"
            ],
            "type": "string",
            "description": "Format of the text pasted into `inlineData`.",
            "default": "csv"
          },
          "inlineViewName": {
            "title": "Pasted data view name",
            "type": "string",
            "description": "View name to reference the pasted data by in `sqlQuery` (only used if `inlineData` is set).",
            "default": "data"
          },
          "inputFiles": {
            "title": "Input files",
            "type": "array",
            "description": "Requires Mode = paid. Source files to download and load into DuckDB as queryable views. Each entry is an object with `name` (view name to use in `sqlQuery`), `url` (http(s):// URL to download, or a local file path), and optional `format` (one of auto, csv, tsv, json, ndjson, parquet, excel, avro, sqlite — 'auto' guesses from the extension/content-type). Supports every file format DuckDB reads natively: CSV/TSV, JSON, NDJSON/JSONL, Parquet, Excel (.xlsx/.xls), Avro, and SQLite.",
            "items": {
              "type": "object"
            },
            "default": []
          },
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "Requires Mode = paid. ID of an Apify dataset to load as a queryable view (e.g. the default dataset of an upstream scraper's run) — for post-processing another Actor's output straight from an integration. Loaded as the view named in `datasetViewName` (default `dataset`). Combine with `inputFiles` to join scraped data against a lookup file."
          },
          "datasetViewName": {
            "title": "Dataset view name",
            "type": "string",
            "description": "View name to reference the loaded dataset by in `sqlQuery` (only used if `datasetId` is set).",
            "default": "dataset"
          },
          "extensions": {
            "title": "Extra DuckDB extensions",
            "type": "array",
            "description": "Additional DuckDB extensions to INSTALL and LOAD before running the query (beyond httpfs/json/parquet/excel/sqlite/avro, which are always loaded). E.g. `iceberg`, `delta`, `postgres`, `mysql`, `spatial` — use their SQL functions (iceberg_scan, delta_scan, postgres_attach, ...) directly in `sqlQuery`.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "maxRows": {
            "title": "Max output rows",
            "minimum": 1,
            "type": "integer",
            "description": "Safety cap on the number of result rows pushed to the dataset. Leave empty for no cap."
          },
          "exportFormat": {
            "title": "Export result as downloadable file",
            "enum": [
              "none",
              "csv",
              "json",
              "parquet",
              "excel"
            ],
            "type": "string",
            "description": "Save the full query result as a single file in the key-value store, in this format. The run log and OUTPUT record then include a direct public download URL — useful when the caller wants a plain file rather than (or in addition to) dataset rows.",
            "default": "none"
          },
          "skipDatasetPush": {
            "title": "Skip pushing rows to the dataset",
            "type": "boolean",
            "description": "If enabled, result rows are not pushed to the Actor's dataset — only the `exportFormat` file is produced. Requires `exportFormat` to not be `none`. Useful when you only want a downloadable file (e.g. a full Excel/CSV export) and don't need dataset-per-row output.",
            "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}