{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Import & Export: Dataset to Sheet, Sheet to JSON",
    "description": "Write any Apify dataset or JSON rows to Google Sheets (append or replace, header merge, dedup), or read a sheet tab or range as JSON rows. No OAuth: share the sheet with our service-account email once. Built for scraper → sheet pipelines and AI agents. $0.01 per 1,000 rows.",
    "version": "0.1",
    "x-build-id": "lolCw4YDbeCmyE3Kh"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/swillz~google-sheets-import-export/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-swillz-google-sheets-import-export",
        "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/swillz~google-sheets-import-export/runs": {
      "post": {
        "operationId": "runs-sync-swillz-google-sheets-import-export",
        "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/swillz~google-sheets-import-export/run-sync": {
      "post": {
        "operationId": "run-sync-swillz-google-sheets-import-export",
        "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": [
          "spreadsheet"
        ],
        "properties": {
          "operation": {
            "title": "Operation",
            "enum": [
              "write",
              "read"
            ],
            "type": "string",
            "description": "\"write\" (default): export an Apify dataset or JSON rows to the sheet. \"read\": import a sheet tab or range into this run's dataset as JSON rows. With no datasetId or rawData, the run reads the sheet instead.",
            "default": "write"
          },
          "spreadsheet": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Required. Full Google Sheets URL, e.g. \"https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit\". The sheet must first be shared (Editor for write, Viewer for read) with sheets-tool@apify-tools-512508.iam.gserviceaccount.com (Share button, paste the email, untick \"Notify people\"). AI agents: ask the user to share it if you get a permission error. Not needed with your own service account key. The prefilled URL is Google's public sample sheet, so a first run with no other input reads it into a dataset; replace it with your own sheet."
          },
          "sheetName": {
            "title": "Sheet tab name",
            "type": "string",
            "description": "Tab to read or write. Leave empty for the tab in the URL (gid) or the first tab. When writing, a missing tab is created for you."
          },
          "datasetId": {
            "title": "Dataset ID (write)",
            "type": "string",
            "description": "String: the Apify dataset ID to export, e.g. \"aBcD1234efGH5678\" from a run's Storage tab. In an integration (run this after another actor finishes) use {{resource.defaultDatasetId}}. Leave empty when you use rawData."
          },
          "writeMode": {
            "title": "Write mode",
            "enum": [
              "append",
              "replace"
            ],
            "type": "string",
            "description": "\"append\" (default): add rows below the existing data; new columns are added to the header. \"replace\": overwrite the tab with the new data; old rows are cleared only after the new data is written.",
            "default": "append"
          },
          "deduplicateBy": {
            "title": "Deduplicate by columns",
            "type": "array",
            "description": "Array of column names, e.g. [\"url\"] or [\"id\"]. Skips rows whose values in these columns already exist (in the sheet when appending, and within the data). Skipped rows are free. Works for read too.",
            "items": {
              "type": "string"
            }
          },
          "columns": {
            "title": "Columns (optional)",
            "type": "array",
            "description": "Array of column names to keep, in this order, e.g. [\"name\",\"price\",\"address.city\"]. Nested fields use dots. Leave empty for all fields.",
            "items": {
              "type": "string"
            }
          },
          "arrayHandling": {
            "title": "Arrays",
            "enum": [
              "join",
              "json",
              "expand"
            ],
            "type": "string",
            "description": "How to put arrays into cells: join simple lists with commas, store as JSON, or expand into numbered columns (tags/0, tags/1…).",
            "default": "join"
          },
          "valueInputOption": {
            "title": "Cell values",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "\"RAW\" (default) stores text exactly as-is (safe: values starting with = are not run as formulas). \"USER_ENTERED\" lets Google parse numbers, dates and formulas as if typed.",
            "default": "RAW"
          },
          "rawData": {
            "title": "Raw data (write, instead of a dataset)",
            "type": "array",
            "description": "Optional array of objects to write instead of a dataset, e.g. [{\"name\":\"A\",\"price\":1},{\"name\":\"B\",\"price\":2}]."
          },
          "range": {
            "title": "Range (read)",
            "type": "string",
            "description": "Optional A1 range within the tab, e.g. \"A1:F500\" or \"B:D\". Leave empty for the whole tab."
          },
          "valueRender": {
            "title": "Read values as",
            "enum": [
              "FORMATTED_VALUE",
              "UNFORMATTED_VALUE"
            ],
            "type": "string",
            "description": "Read only. \"FORMATTED_VALUE\" (default): what you see in the sheet, e.g. \"$1.50\". \"UNFORMATTED_VALUE\": raw numbers and booleans.",
            "default": "FORMATTED_VALUE"
          },
          "skipEmptyRows": {
            "title": "Skip empty rows",
            "type": "boolean",
            "description": "Read only: ignore fully empty rows (default true).",
            "default": true
          },
          "headerRow": {
            "title": "First row is a header",
            "type": "boolean",
            "description": "Read: use row 1 as field names. Write: write/merge column names into row 1.",
            "default": true
          },
          "maxRows": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many rows (0 = no limit).",
            "default": 0
          },
          "serviceAccountKey": {
            "title": "Your own service account key (optional)",
            "type": "string",
            "description": "Advanced: paste the full JSON key of your own Google Cloud service account (with Sheets and Drive APIs enabled). Then share your sheet with that account's email instead of ours. Stored encrypted as a secret input."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}