{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Export & Sync for Apify Datasets",
    "description": "Export an Apify dataset to Google Sheets: append, replace or upsert by key. Service account or Apps Script, works as an integration. $0.80 per 1,000 rows.",
    "version": "0.0",
    "x-build-id": "EN3Q3JiI1lJY4zdNA"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/ottomath~dataset-to-google-sheets/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-ottomath-dataset-to-google-sheets",
        "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/ottomath~dataset-to-google-sheets/runs": {
      "post": {
        "operationId": "runs-sync-ottomath-dataset-to-google-sheets",
        "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/ottomath~dataset-to-google-sheets/run-sync": {
      "post": {
        "operationId": "run-sync-ottomath-dataset-to-google-sheets",
        "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": {
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "The dataset to export: its ID (Apify Console > Storage > Datasets) or a name such as username~my-dataset. When this Actor runs as an integration of another Actor or task, enter {{resource.defaultDatasetId}} (or leave the field empty) to export the dataset of the run that triggered it. Without Google credentials, an empty field previews a built-in sample of 5 items."
          },
          "spreadsheetUrl": {
            "title": "Spreadsheet address",
            "type": "string",
            "description": "The address of the Google Sheet as shown in the browser, for example https://docs.google.com/spreadsheets/d/1AbC.../edit. Fill in this field or the spreadsheet ID. With the Apps Script method you can leave both empty: the script writes to the spreadsheet it belongs to."
          },
          "spreadsheetId": {
            "title": "Spreadsheet ID",
            "type": "string",
            "description": "Alternative to the address: the long ID between /d/ and /edit in the address of the sheet. An address pasted here also works."
          },
          "sheetName": {
            "title": "Tab name",
            "minLength": 1,
            "maxLength": 100,
            "type": "string",
            "description": "The tab (worksheet) to write to. It is created when it does not exist yet.",
            "default": "Sheet1"
          },
          "mode": {
            "title": "Write mode",
            "enum": [
              "append",
              "replace",
              "upsert"
            ],
            "type": "string",
            "description": "Append adds the items below the existing rows. Replace clears the tab first and writes the dataset. Upsert updates the rows whose key columns match and appends the others, so running the same export again never creates duplicates.",
            "default": "append"
          },
          "keyColumns": {
            "title": "Key columns (upsert)",
            "maxItems": 10,
            "type": "array",
            "description": "Required for upsert. One or more column names that together identify a row, for example url or id. Names are case-sensitive; nested fields are written like address.city. Rows without a value in these columns are skipped.",
            "items": {
              "type": "string"
            }
          },
          "authMode": {
            "title": "Sign-in method",
            "enum": [
              "auto",
              "serviceAccount",
              "appsScript"
            ],
            "type": "string",
            "description": "How the Actor gets permission to write to your sheet. Automatic uses the method whose fields below are filled in.",
            "default": "auto"
          },
          "serviceAccountJson": {
            "title": "Service account key (JSON)",
            "type": "string",
            "description": "Service account method: paste the whole content of the JSON key file of a Google Cloud service account, and share the spreadsheet with its client_email address as Editor."
          },
          "appsScriptUrl": {
            "title": "Apps Script web app URL",
            "type": "string",
            "description": "Apps Script method: the web app URL that ends with /exec, from Deploy > New deployment in the script of your spreadsheet."
          },
          "appsScriptToken": {
            "title": "Apps Script secret token",
            "type": "string",
            "description": "Apps Script method: the SECRET_TOKEN you wrote in the script (at least 12 characters). Requests without it are rejected."
          },
          "columns": {
            "title": "Columns",
            "maxItems": 2000,
            "type": "array",
            "description": "Optional: the columns to write, in this order. Leave empty to write every field of the items (the union of all fields, in order of first appearance). Nested fields are written like address.city.",
            "items": {
              "type": "string"
            }
          },
          "flatten": {
            "title": "Flatten nested data",
            "type": "boolean",
            "description": "On: nested objects become columns with dotted names (address.city) and lists of text or numbers are joined with \", \". Off: only top-level fields become columns and nested values are written as JSON text. Lists that contain objects are always written as JSON text.",
            "default": true
          },
          "includeHeader": {
            "title": "Write a header row",
            "type": "boolean",
            "description": "On: row 1 holds the column names. If the tab already has a header, the new data is aligned to it and new columns are added at the end. Off: only data rows are written (not possible with upsert).",
            "default": true
          },
          "valueInputOption": {
            "title": "How Google reads the values",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "Raw stores every value exactly as it is (text stays text, nothing becomes a date or a formula). User entered lets Google Sheets interpret numbers and dates as if typed; text that starts with =, +, - or @ is still kept as plain text, so exported data never runs as a formula.",
            "default": "RAW"
          },
          "maxItems": {
            "title": "Maximum number of items",
            "minimum": 1,
            "type": "integer",
            "description": "Optional cap on the number of dataset items to export. Leave empty to export everything."
          },
          "dryRun": {
            "title": "Preview only (dry run)",
            "type": "boolean",
            "description": "On: read up to 100 items and show in the output the columns and rows that would be written, without contacting Google and without charging for rows. The Actor does the same, whatever this setting says, when no Google credentials are entered. Off: write to the spreadsheet as soon as Google credentials are entered.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}