# Google Sheets Export - No Google Cloud, Append Only New Rows (`radarweb/google-sheets-export-reliable`) Actor

Send any dataset to a Google Sheet with a 2-minute Apps Script (no Google Cloud, no OAuth that expires) or a service account. Replace, append, or append only new rows; flattens nested data; formula-safe; retries rate limits.

- **URL**: https://apify.com/radarweb/google-sheets-export-reliable.md
- **Developed by:** [Riccardo Bonadio](https://apify.com/radarweb) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 row writtens

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Google Sheets Export: reliable dataset to sheet

Send the results of any Apify Actor straight into a **Google Sheet**, **without creating a Google Cloud project**: replace the sheet, append rows, or **append only the new rows** so a weekly run never creates duplicates.

### Why this exporter

- **No login that expires.** Connect with a 2-minute **Apps Script** (no Google Cloud at all) or a Google *service account*. Neither depends on a personal sign-in, so scheduled runs keep working for months. Most export failures come from expired Google sign-ins.
- **Append only new rows.** Choose a key column (`url`, `id`, `email`…) and rows already in the sheet are skipped.
- **Keep the sheet in sync.** *Update existing rows* refreshes each row in place (same key, new price, rating or stock) and adds new ones: one living sheet instead of a growing pile of duplicates.
- **Your sheet stays yours.** Append modes keep your column order. New fields become new columns at the end. A missing tab is created for you.
- **Nested data becomes columns.** `address.city`, `address.zip`. Lists of text become `cafe, bar`.
- **Safe by default.** Values are written as plain text/numbers, so scraped text like `=IMPORTXML(...)` can never run as a formula in your sheet.
- **Big datasets.** Rows are streamed in batches. Google rate limits (HTTP 429) are retried automatically with back-off.
- **Clear errors.** "Share the sheet with robot@project.iam.gserviceaccount.com", not a stack trace.

### Setup option A: Apps Script, no Google Cloud (2 minutes, recommended)

1. Open your Google Sheet → **Extensions → Apps Script**.
2. Delete the sample code and paste the script from this Actor's source (`apps_script/Code.gs`, also shown in the *Source* tab).
3. In the script, replace `CHANGE-ME-to-a-long-random-password` with your own long password.
4. **Deploy → New deployment →** type **Web app**, *Execute as*: **Me**, *Who has access*: **Anyone** → **Deploy**, and approve the permissions.
5. Copy the **Web app URL** (ends with `/exec`) into *Apps Script web app URL*, and your password into *Apps Script secret*.

The script only accepts requests carrying your password, and can only touch the spreadsheet it lives in.

### Setup option B: Google service account (advanced, for teams and many sheets)

1. Go to <https://console.cloud.google.com/> and create (or pick) a project.
2. Open **APIs & Services → Library**, search for **Google Sheets API** and press **Enable**.
3. Open **IAM & Admin → Service accounts → Create service account**. Any name works. Skip the optional steps.
4. Open the new service account → **Keys → Add key → Create new key → JSON**. A `.json` file downloads.
5. Open your Google Sheet → **Share** → paste the service account's email (`…@….iam.gserviceaccount.com`) → **Editor**.
6. Paste the **content** of the JSON file into *Google service-account key* (stored encrypted) and the sheet URL into *Google Sheet URL*.

### Run it automatically after a scraper

In your scraper's **Integrations** tab add this Actor ("Run Actor after the run succeeds"). Leave *Dataset ID* empty: it picks up the scraper's dataset automatically. Use mode **Append only new rows** for a sheet that grows without duplicates.

### Output

The sheet itself, plus an `OUTPUT` record with rows written, duplicates skipped, column count and the sheet URL.

### Limits

Google Sheets allows up to 10 million cells per spreadsheet and 50,000 characters per cell (longer text is truncated with "…").

### Pricing

Pay per row written (see the Pricing tab). Skipped duplicates are free.

### Try it

Type `demo` as *Dataset ID* to send built-in sample data to your sheet.

# Actor input Schema

## `appsScriptUrl` (type: `string`):

No Google Cloud needed: paste our small script into your sheet (Extensions → Apps Script), deploy it as a Web app and paste its /exec URL here. Step-by-step in the README.

## `appsScriptSecret` (type: `string`):

The same password you set as SECRET in the script.

## `spreadsheet` (type: `string`):

Only for the service-account option. Share the sheet with the service account's email as Editor.

## `serviceAccountKey` (type: `string`):

The JSON key file of a Google Cloud service account with the Google Sheets API enabled. Stored encrypted. See the README for the 3-minute setup.

## `datasetId` (type: `string`):

The dataset to export. Leave empty when this Actor runs as an integration after another Actor: it then uses that run's dataset automatically. Pick a dataset (ID or name). Leave empty to try it with built-in sample data.

## `sheetName` (type: `string`):

Created if it does not exist.

## `mode` (type: `string`):

'Update existing rows' keeps one row per key and refreshes it every run: perfect for price lists, rankings, stock levels. Your column order is kept; new fields become new columns.

## `uniqueKey` (type: `string`):

Column that identifies a row, e.g. url, id or email. Nested fields use dots: address.city.

## `columns` (type: `array`):

Export only these columns, in this order. Leave empty to export all fields.

## `flatten` (type: `boolean`):

Turn {"address": {"city": "Rome"}} into a column 'address.city'; lists of text become comma-separated.

## `parseFormulasAndNumbers` (type: `boolean`):

Off (recommended): values are written exactly as they are, so scraped text starting with '=' can never run as a formula. On: Google parses text like a user typing it.

## `maxRows` (type: `integer`):

0 = no limit.

## Actor input object example

```json
{
  "sheetName": "Apify data",
  "mode": "replace",
  "columns": [],
  "flatten": true,
  "parseFormulasAndNumbers": false,
  "maxRows": 0
}
```

# Actor output Schema

## `output` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("radarweb/google-sheets-export-reliable").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("radarweb/google-sheets-export-reliable").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call radarweb/google-sheets-export-reliable --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,radarweb/google-sheets-export-reliable"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/HnWmtLdFXXQo31G1R/builds/CdrbHgjlIj21lbPAr/openapi.json
