{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Import & Export: Append & Dedupe",
    "description": "Export any Apify dataset to Google Sheets or import a sheet to JSON/CSV. Append or replace, skip duplicates by a key column, map columns. Service account key (no expiring login), clear setup errors, public sheets without a key.",
    "version": "0.1",
    "x-build-id": "EEfOvqAp7pvZjLywY"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/ctriolab~google-sheets-import-export/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-ctriolab-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/ctriolab~google-sheets-import-export/runs": {
      "post": {
        "operationId": "runs-sync-ctriolab-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/ctriolab~google-sheets-import-export/run-sync": {
      "post": {
        "operationId": "run-sync-ctriolab-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": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "import",
              "export",
              "append",
              "replace",
              "read"
            ],
            "type": "string",
            "description": "Import reads rows from a sheet into this run's dataset. Export writes rows from an Apify dataset (or inline JSON) into a sheet. The legacy values append, replace and read accept input written for lukaskrivka/google-sheets (README: Switching from lukaskrivka/google-sheets).",
            "default": "import"
          },
          "spreadsheet": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Paste the address bar URL of the sheet (https://docs.google.com/spreadsheets/d/<ID>/edit#gid=...) or just the ID. For public import without a key, the #gid=... part picks the tab."
          },
          "serviceAccountKey": {
            "title": "Service account JSON key",
            "type": "string",
            "description": "Required for export and for private sheets. Paste the whole JSON key file of a Google Cloud service account, then share the sheet with its client_email (Editor for export, Viewer for import). Stored encrypted. Leave empty to import a sheet shared as \"Anyone with the link can view\". Setup steps are in the README."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "Tab (sheet) to read or write. Empty: the tab from #gid in the URL, else the first tab. Export creates the tab if it does not exist. Needs a service account key."
          },
          "range": {
            "title": "Range (import)",
            "type": "string",
            "description": "Optional A1 range for import, e.g. A1:F500, A:D or 2:100. Empty: the whole tab. The first row of the range is the header when 'First row is header' is on."
          },
          "datasetId": {
            "title": "Dataset to export",
            "type": "string",
            "description": "Apify dataset to write to the sheet. In an integration after another Actor use {{resource.defaultDatasetId}}. Nested fields become columns like address/city, tags/0."
          },
          "rows": {
            "title": "Inline rows (JSON)",
            "type": "array",
            "description": "Instead of a dataset: a JSON array of objects [{\"name\":\"A\"}] or of arrays with a header row first [[\"name\"],[\"A\"]]. Apify inputs are limited to 9 MB, use a dataset for more."
          },
          "writeMode": {
            "title": "Write mode",
            "enum": [
              "append",
              "replace"
            ],
            "type": "string",
            "description": "Append keeps existing rows and columns in place and adds new rows at the bottom. Replace writes the new table from A1 and then clears the rest of the tab.",
            "default": "append"
          },
          "dedupeKey": {
            "title": "Skip duplicates by column (append)",
            "type": "string",
            "description": "Column name (e.g. url or id). Rows whose value already exists in this column of the sheet, or appears twice in the new data, are not written and not charged. Rows with an empty value are always written."
          },
          "addNewColumns": {
            "title": "Add new columns (append)",
            "type": "boolean",
            "description": "When the data has fields that the sheet header does not have, add them as new columns at the right end. Off: such fields are skipped.",
            "default": true
          },
          "parseValues": {
            "title": "Let Google parse values",
            "type": "boolean",
            "description": "Off (recommended): values are written exactly as given, text that starts with = is not run as a formula. On: Google parses values like typed by a user (dates, percentages, formulas).",
            "default": false
          },
          "headerRow": {
            "title": "First row is header",
            "type": "boolean",
            "description": "Import: use the first row as field names (else A, B, C...). Export: write a header row (else data only).",
            "default": true
          },
          "columns": {
            "title": "Columns to keep (in order)",
            "type": "array",
            "description": "Optional. Field names to keep, in this order. Import: sheet header names. Export: dataset field names (nested as a/b). Empty: all columns.",
            "items": {
              "type": "string"
            }
          },
          "columnNames": {
            "title": "Rename columns",
            "type": "object",
            "description": "Optional mapping from source field to new name, e.g. {\"price\": \"Price (USD)\", \"url\": \"Link\"}."
          },
          "readValues": {
            "title": "Read values as (import with key)",
            "enum": [
              "formatted",
              "raw"
            ],
            "type": "string",
            "description": "Formatted returns text like \"$1,200.00\". Raw returns 1200. Public import (no key) always returns formatted text.",
            "default": "formatted"
          },
          "maxItems": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many rows (0 = no limit). Also caps cost.",
            "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
                  },
                  "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}