{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Export: Append, Upsert & Dedupe",
    "description": "Export Apify datasets or JSON to Google Sheets. Append, append only new rows, upsert by key, or replace with backup. Read tabs back into datasets.",
    "version": "0.1",
    "x-build-id": "LtbNNfktyg2Cbau89"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/codemagnet~google-sheets-export/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-codemagnet-google-sheets-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/codemagnet~google-sheets-export/runs": {
      "post": {
        "operationId": "runs-sync-codemagnet-google-sheets-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/codemagnet~google-sheets-export/run-sync": {
      "post": {
        "operationId": "run-sync-codemagnet-google-sheets-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",
        "properties": {
          "datasetId": {
            "title": "Dataset to export",
            "type": "string",
            "description": "Pick a dataset, for example the results of a scraper run. When this Actor runs as an integration after another Actor, it uses that run's dataset automatically."
          },
          "rawData": {
            "title": "Or paste JSON data",
            "type": "array",
            "description": "A JSON array of objects. Used only when no dataset is selected."
          },
          "spreadsheet": {
            "title": "Spreadsheet link",
            "type": "string",
            "description": "The full link from your browser, like https://docs.google.com/spreadsheets/d/.../edit. Required with a service account; optional with the connector (it already knows its spreadsheet)."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "The tab to write to. Created if it doesn't exist. Leave empty to use the first tab."
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "append-new",
              "upsert",
              "replace",
              "read"
            ],
            "type": "string",
            "description": "How rows are written. Append new only and Upsert need key columns. Replace saves the old contents to the run's key-value store first.",
            "default": "append"
          },
          "keyColumns": {
            "title": "Key columns",
            "type": "array",
            "description": "Columns that identify a row, such as url or id. Needed for Append new only and Upsert. Use several for a combined key.",
            "items": {
              "type": "string"
            }
          },
          "connection": {
            "title": "How to connect to Google",
            "enum": [
              "appsScript",
              "serviceAccount"
            ],
            "type": "string",
            "description": "See the README for 3-minute setup steps for either option.",
            "default": "appsScript"
          },
          "appsScriptUrl": {
            "title": "Connector URL",
            "type": "string",
            "description": "The Web app URL of the connector script, ending in /exec."
          },
          "appsScriptSecret": {
            "title": "Connector secret",
            "type": "string",
            "description": "The SECRET you set at the top of the connector script."
          },
          "serviceAccountKey": {
            "title": "Service account key (JSON)",
            "type": "string",
            "description": "Paste the whole JSON key file. Then share the spreadsheet with the service account's email as an Editor."
          },
          "fields": {
            "title": "Columns to include",
            "type": "array",
            "description": "Only these columns, in this order. Nested fields use dots, like seller.name. Leave empty for all columns.",
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Columns to leave out",
            "type": "array",
            "description": "Columns to skip, such as html or debug fields.",
            "items": {
              "type": "string"
            }
          },
          "nestedData": {
            "title": "Nested data",
            "enum": [
              "flatten",
              "json"
            ],
            "type": "string",
            "description": "With Flatten, objects that vary a lot between items (for example keyed by IDs) still stay as JSON in one column, so the sheet doesn't explode into thousands of columns.",
            "default": "flatten"
          },
          "addNewColumns": {
            "title": "Add new columns",
            "type": "boolean",
            "description": "When the data has columns the tab doesn't, add them at the right end of the header. Turn off to keep the tab's columns fixed.",
            "default": true
          },
          "valueInput": {
            "title": "How values are stored",
            "enum": [
              "raw",
              "parse"
            ],
            "type": "string",
            "description": "Keep the default for scraped data: interpreting values would let text from websites run as spreadsheet formulas.",
            "default": "raw"
          },
          "offset": {
            "title": "Skip first items",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many items (or rows, in Read mode) from the start."
          },
          "limit": {
            "title": "Maximum items",
            "minimum": 1,
            "type": "integer",
            "description": "Export at most this many items (or read at most this many rows)."
          },
          "dryRun": {
            "title": "Dry run",
            "type": "boolean",
            "description": "Connect and plan, but don't change the spreadsheet. Shows what would be appended, updated and skipped. Free.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}