{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Writer — export datasets to Sheets",
    "description": "Export any Apify dataset to Google Sheets, or read a tab back. Service account, OAuth refresh token, or a one-minute pasted access token. Every precondition checked before the first cell, and values written RAW so a scraped \"=…\" never becomes a formula.",
    "version": "0.1",
    "x-build-id": "qXFn0tt5oyJxf4CCv"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/leonguyen2808~google-sheets-writer/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-leonguyen2808-google-sheets-writer",
        "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/leonguyen2808~google-sheets-writer/runs": {
      "post": {
        "operationId": "runs-sync-leonguyen2808-google-sheets-writer",
        "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/leonguyen2808~google-sheets-writer/run-sync": {
      "post": {
        "operationId": "run-sync-leonguyen2808-google-sheets-writer",
        "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": [
          "spreadsheetUrlOrId"
        ],
        "properties": {
          "spreadsheetUrlOrId": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Paste the sheet's URL or just its id. Both work — the id is the part between /d/ and /edit."
          },
          "serviceAccountKey": {
            "title": "Service account key (JSON) — most reliable",
            "type": "string",
            "description": "Most reliable: never expires. Needs a Google Cloud project — Console → IAM & Admin → Service Accounts → Keys → Add key (JSON). Then Share the sheet with the key's client_email as Editor. Leave empty if you use one of the OAuth fields instead."
          },
          "oauthAccessToken": {
            "title": "Access token — easiest, one-off",
            "type": "string",
            "description": "Easiest option, no Google Cloud project needed: open developers.google.com/oauthplayground, pick the scope https://www.googleapis.com/auth/spreadsheets, authorise your own Google account and paste the access token here. It lasts about an hour, so use it for a single run rather than a schedule."
          },
          "oauthRefreshToken": {
            "title": "Refresh token — survives across runs",
            "type": "string",
            "description": "Use this for scheduled runs without a service account. Needs oauthClientId and oauthClientSecret too. Note: if your OAuth app is still in Testing status, Google expires refresh tokens after 7 days."
          },
          "oauthClientId": {
            "title": "OAuth client ID",
            "type": "string",
            "description": "The OAuth client the refresh token was issued to."
          },
          "oauthClientSecret": {
            "title": "OAuth client secret",
            "type": "string",
            "description": "The secret of that OAuth client."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "Which tab inside the spreadsheet. Created automatically if it does not exist.",
            "default": "Sheet1"
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "replace",
              "read"
            ],
            "type": "string",
            "description": "Append inserts new rows and never overwrites what is below them. Replace clears the tab first. Read pulls the tab back out as dataset items.",
            "default": "append"
          },
          "datasetId": {
            "title": "Dataset ID (source)",
            "type": "string",
            "description": "Which dataset to write. Leave empty to use this run's own default dataset (the usual case when chained after another Actor).",
            "default": ""
          },
          "rows": {
            "title": "Rows (instead of a dataset)",
            "type": "array",
            "description": "An array of objects to write directly. Takes precedence over datasetId when non-empty.",
            "default": []
          },
          "columns": {
            "title": "Column order",
            "type": "array",
            "description": "Explicit column order. Empty means first-seen field order across the data, which preserves the layout the producing Actor chose.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "includeHeaders": {
            "title": "Write a header row",
            "type": "boolean",
            "description": "On for replace mode. Turn off when appending to a sheet that already has headers.",
            "default": true
          },
          "createSheetIfMissing": {
            "title": "Create the tab if missing",
            "type": "boolean",
            "description": "Off makes a wrong tab name an error instead of a new tab — useful when the sheet layout is fixed.",
            "default": true
          },
          "letSheetsParseValues": {
            "title": "Let Sheets parse values (dates, numbers)",
            "type": "boolean",
            "description": "Off by default, and deliberately: with parsing ON, Google rewrites scraped values — a cell starting with = becomes a live formula, and the leading + or 0 is stripped from phone numbers and zip codes. Turn it on only when you want date strings to become real dates and accept that trade.",
            "default": false
          },
          "limit": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "0 means no limit.",
            "default": 0
          },
          "offset": {
            "title": "Skip rows",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many rows from the start of the dataset. Useful for writing a large dataset across several runs.",
            "default": 0
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}