{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Sync: Export Datasets & JSON to Sheets",
    "description": "Export any Apify dataset or JSON to Google Sheets reliably. Append, replace or dedupe/upsert rows by key, batch 100k+ rows, auto-retry Google errors, clear fixes in every error. Official Sheets API, your own service account.",
    "version": "1.0",
    "x-build-id": "uALzXO81ZMLCgGmb5"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/genesis.labs.co~google-sheets-sync/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-genesis.labs.co-google-sheets-sync",
        "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/genesis.labs.co~google-sheets-sync/runs": {
      "post": {
        "operationId": "runs-sync-genesis.labs.co-google-sheets-sync",
        "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/genesis.labs.co~google-sheets-sync/run-sync": {
      "post": {
        "operationId": "run-sync-genesis.labs.co-google-sheets-sync",
        "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": {
          "spreadsheet": {
            "title": "Google Sheet URL or ID",
            "type": "string",
            "description": "Paste the full URL of your Google Sheet (or just its ID). A URL with #gid=… selects that tab."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "Name of the tab to write to. Created automatically if it doesn't exist. Leave empty to use the tab from the URL or the first tab."
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "replace",
              "dedupe"
            ],
            "type": "string",
            "description": "append: add rows to the bottom (never rewrites existing data). replace: clear the tab and write fresh data. dedupe: append only rows whose key (see 'Dedupe on') is not already in the sheet; with 'Update existing rows' it becomes an upsert.",
            "default": "append"
          },
          "dedupeOn": {
            "title": "Dedupe on (key fields)",
            "type": "array",
            "description": "Field name(s) that identify a unique row, e.g. url, placeId or email. Required for mode 'dedupe'. Nested fields use dots: author.id",
            "items": {
              "type": "string"
            }
          },
          "updateExisting": {
            "title": "Update existing rows (upsert)",
            "type": "boolean",
            "description": "In dedupe mode, overwrite the existing row when the key already exists instead of skipping it.",
            "default": false
          },
          "datasetId": {
            "title": "Apify dataset ID",
            "type": "string",
            "description": "Dataset to export (pick one or paste its ID). For automatic export after each scraper run, add this Actor as an integration and set this field to {{resource.defaultDatasetId}}."
          },
          "data": {
            "title": "Or: JSON data",
            "type": "array",
            "description": "Array of objects to write instead of a dataset."
          },
          "limit": {
            "title": "Limit items",
            "minimum": 1,
            "type": "integer",
            "description": "Only read this many dataset items."
          },
          "offset": {
            "title": "Offset",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many dataset items.",
            "default": 0
          },
          "serviceAccountJson": {
            "title": "Google service account key (JSON)",
            "type": "string",
            "description": "Recommended. Paste the JSON key of a Google Cloud service account with the Google Sheets API enabled, then share your sheet with the service account's client_email as Editor. Stored encrypted."
          },
          "oauthClientId": {
            "title": "OAuth client ID",
            "type": "string",
            "description": "Your own Google OAuth client ID (alternative to service account)."
          },
          "oauthClientSecret": {
            "title": "OAuth client secret",
            "type": "string",
            "description": "Your own Google OAuth client secret."
          },
          "oauthRefreshToken": {
            "title": "OAuth refresh token",
            "type": "string",
            "description": "Refresh token with the https://www.googleapis.com/auth/spreadsheets scope."
          },
          "columns": {
            "title": "Columns to include (and order)",
            "type": "array",
            "description": "Only write these fields, in this order. Leave empty to write all fields.",
            "items": {
              "type": "string"
            }
          },
          "omitColumns": {
            "title": "Columns to skip",
            "type": "array",
            "description": "Fields to leave out.",
            "items": {
              "type": "string"
            }
          },
          "flatten": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "Turn {a:{b:1}} into a column 'a.b' and arrays into 'list/0', 'list/1' (same as Apify CSV export).",
            "default": true
          },
          "parseValues": {
            "title": "Let Google parse values",
            "type": "boolean",
            "description": "Off (default): values are written exactly as-is, so text like '=SUM()' or '00123' can't turn into formulas or numbers. On: Google parses dates, numbers and formulas like typing them by hand.",
            "default": false
          },
          "clearIfEmpty": {
            "title": "Replace mode: clear sheet if source is empty",
            "type": "boolean",
            "description": "By default an empty dataset leaves the sheet untouched so a failed scrape never wipes your data.",
            "default": false
          },
          "batchSize": {
            "title": "Rows per request",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Rows sent to Google per API call.",
            "default": 1000
          },
          "maxRows": {
            "title": "Max rows to write",
            "minimum": 1,
            "type": "integer",
            "description": "Safety cap on rows written (and charged) in one run."
          },
          "requestsPerMinute": {
            "title": "Max Google requests per minute",
            "minimum": 1,
            "maximum": 600,
            "type": "integer",
            "description": "Stays under Google's default 60 requests/min per user quota. Raise it only if your project has a higher quota.",
            "default": 55
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}