# Dataset to Google Sheets (no OAuth) (`rivetfinch/sheets-export`) Actor

Send any Apify dataset into your Google Sheet. Share the sheet once with our service account: no Google sign-in, no expiring tokens. True append, replace or upsert by key, stable columns, automatic grid growth, retries on Google rate limits. Works after every scraper run as an integration.

- **URL**: https://apify.com/rivetfinch/sheets-export.md
- **Developed by:** [Rivetfinch](https://apify.com/rivetfinch) (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.02 / 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

## Dataset to Google Sheets (no OAuth)

Send any Apify dataset into your own Google Sheet. You share the sheet once with our service account, and from then on every run lands its rows in the same tab: no Google sign-in, no "this app is blocked" screen, no tokens that expire after a week.

### What you get

Your dataset's items become rows in your sheet, one row per item, under a header row that stays put.

| title | price | url | tags | seller.name |
|---|---|---|---|---|
| Blue kettle 1.7 l | 24.99 | shop.example/kettle-blue | kitchen, sale | Acme |
| Steel toaster | 39.00 | shop.example/toaster | kitchen | Acme |

- **Columns stay where they are.** Fields are matched to the header row by name. A field that is new today becomes a new column at the end; columns you already have, including your own extra columns, never move.
- **Append really appends.** Only the new rows are sent, and Google adds them right after your existing rows. Old rows are never rewritten. Several runs appending to the same tab at the same time don't overwrite each other.
- **No doubled rows when Google hiccups or the run restarts.** If Google fails in the middle of adding rows, the Actor checks the sheet before sending them again. If Apify moves or restarts the run, it carries on from the last confirmed chunk, without writing or charging rows twice.
- **Nested data is flattened** into columns such as `seller.name`, and lists become one cell (`kitchen, sale`), JSON text or numbered columns.
- **The sheet grows by itself.** Rows and columns are added before they are needed, so "range exceeds grid limits" never happens.
- **Reliable on schedules and integrations.** An empty dataset is a success, not an error, and never touches your sheet. Google's "too many requests" answers are waited out (up to about 10 minutes) and server errors are retried. Problems you can fix get a plain message that says what to do.
- **A result row per run** in the run's own dataset (and a `SUMMARY` record): rows appended, updated and skipped, columns added, and a link to the tab.

### Setup in 3 steps

1. **Share your sheet** with `sheets-export@rivetfinch-sheets.iam.gserviceaccount.com` as an **Editor**: in Google Sheets click Share, paste the address, choose Editor, untick "Notify people", and click Share.
2. **Add your link code.** Run this Actor once with nothing filled in: the result shows your link code, for example `apify-3f9c2a71b0`. Put it anywhere in the spreadsheet's name ("Leads apify-3f9c2a71b0") or add a tab named exactly that code. You do this once per spreadsheet.
3. **Pick the dataset and paste the sheet's address** (the one in your browser bar), then run.

Why the link code? Everyone shares their sheets with the same service account. The code is tied to your Apify account, so nobody else can use this Actor to write into your sheet, even if they learn its address.

**Good to know about access**

- Our service account keeps Editor access to the sheet until you remove it: Share, find the service-account address, and choose Remove access.
- It only opens your sheet while one of your runs is exporting to it.
- Some Google Workspace organisations block sharing with addresses outside the organisation. If Share refuses the address, ask your admin, or use your own service account (below).

**Your own service account.** Paste a Google service-account JSON key under **Your own service account key** (stored encrypted) and share the sheet with that account's address instead. No link code is needed, and your runs use your own Google quota. This is the better choice for heavy volume, and for AI agents and automated tools.

### Modes

| Mode | What it does |
|---|---|
| **Append** (default) | Adds the dataset's rows after the rows already in the tab. Turn on **skip rows whose key is already in the sheet** to add only new items (for example by `url`). |
| **Replace** | Writes the dataset over the tab from the top, then clears whatever is left below and to the right, so the tab is never blank while the run works. By default the tab's existing column order is kept (charts and formulas keep working) and new fields go at the end; turn off **keep the existing column order** for a fresh header. |
| **Upsert** | Rows whose **key columns** match an item are updated in place; the rest are appended. Fields missing from an item leave those cells as they are; fields that are empty in the item clear their cells. |

Other options: the tab name (created if missing), which columns to write and in what order, how arrays are flattened, and whether Google should read values raw (exact text, the default) or as typed (numbers and dates are recognised). With "as typed", text starting with `=` is still stored as text unless you turn on **allow formulas**, so scraped data can't run formulas in your sheet.

### Use it after every scraper run

Add this Actor as an **integration** on your scraper or task (Integrations tab, run this Actor when the run succeeds). Fill in the spreadsheet and tab; the **Dataset** field is filled in for you with the dataset of the run that triggered it. If that field ends up empty, the Actor tries the dataset named in the integration's payload, but Apify may refuse that read under this Actor's limited permissions, so keep the Dataset field set.

It also works from schedules and the API: everything is plain input fields, with no account connection step. Input names used by other Sheets Actors (`datasetId`, `spreadsheetId`) are accepted too.

### Pricing

**$0.02 per 1,000 rows** written (appended or updated). Skipped rows, empty items, header cells and the result row are free. Your run's maximum cost is respected: the export stops cleanly at that limit and charges only rows that were written.

### Limits

- **Google's size limit:** a spreadsheet holds up to 20 million cells, counting every tab and empty cells too. Close to that limit the Actor fills the tab's empty rows first; then it stops cleanly, keeps what it wrote, and tells you. Filling empty rows assumes only one run writes to the tab at that point.
- **Cells over 50,000 characters** are cut to Google's limit and marked `…[truncated]`; the result counts them.
- **Google's rate limits:** Google caps how many requests a minute one service account may make, and our service account is shared by everyone using this Actor. When Google says "too many requests", the Actor waits and retries for up to about 10 minutes, so large exports can be slow at busy times. Heavy users should bring their own service-account key.
- **Header row:** row 1 of the tab is the header. New rows go right after the block of rows under the header; if you leave a completely empty row inside your data, new rows are added at that point and the rows below move down (nothing is overwritten).
- **Runs at the same time:** appends from several runs into one tab are safe. If those runs bring different new columns, run them one after another the first time so the header settles. Replace and Upsert assume one run at a time on a tab.
- **Empty items** (every field empty) are left out, and not charged.
- **Memory:** the default 256 MB handles 100,000-row exports and upserts. An upsert into a sheet with about 1 million rows needs 512 MB.
- **Excel files** stored in Google Drive must be saved as Google Sheets first (File > Save as Google Sheets).
- The Actor writes into sheets you own and share; it doesn't create new spreadsheet files.
- If a run fails part-way, rows it already wrote stay in the sheet; for the re-run use Upsert or "skip rows whose key is already in the sheet" so they aren't added twice.

### Result status

| Status | Meaning, and what to do |
|---|---|
| `ok` | Done. |
| `partial` | Some rows were written, then the spreadsheet filled up or the run reached its maximum cost. The message says which. |
| `empty` | The dataset had no items. Nothing was written; not an error. |
| `dryRun` | No dataset and no spreadsheet given. Shows the service-account address and your link code. |
| `setupOk` | Spreadsheet given but no dataset: sharing and the link code were checked, nothing was written. |
| `notShared` | Share the sheet with the service-account address in the message, as Editor. |
| `readOnly` | The service account is a Viewer or Commenter. Change it to Editor. |
| `notLinked` | Add the link code from the message to the spreadsheet's name, or add a tab with that name. |
| `notFound` | No spreadsheet with that address. Copy it again from the browser bar. |
| `notASheet` | The file is an Excel file in Drive. Save it as a Google Sheet first. |
| `sheetFull` | No room left (20-million-cell limit). Delete unused tabs, rows or columns, or use a new spreadsheet. |
| `badTab` | Google couldn't use the tab name. Check Sheet name. |
| `datasetAccess` | The run may not read the dataset. Pick it in the Dataset field. |
| `invalidInput` | An input can't be used, or an input name is misspelled; the message names it. |
| `invalidKey` | Your service-account key isn't a valid JSON key. Download a new one. |
| `notConfigured` | The shared service account can't be used for this run. Run again, or use your own key. |
| `apiDisabled` | The Google Sheets API is off in your service account's Google Cloud project. Turn it on. |
| `quota` | Google kept saying "too many requests" for about 10 minutes. Run later, or use your own key. |
| `googleError` | Google kept failing. Run again later. |
| `internalError` | Something unexpected went wrong; the message and run log say what. |

Not affiliated with Google. Google Sheets is a trademark of Google LLC.

# Actor input Schema

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

The address of your Google Sheet from the browser bar, for example https://docs.google.com/spreadsheets/d/1AbC.../edit#gid=0, or just its ID (any length). If the address points at a tab (#gid=...), that tab is used.

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

Which tab to write to. Created if it doesn't exist. Leave empty to use the tab in the address, or else the first tab.

## `dataset` (type: `string`):

The dataset to export. When this Actor runs as an integration after another Actor's run, this is filled in for you with that run's dataset.

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

Append adds the dataset's rows after the last row in the tab and never touches existing rows. Replace clears the tab's values (formatting stays) and writes the dataset. Upsert updates rows whose key columns match and appends the rest.

## `keyColumns` (type: `array`):

Column names that identify a row, such as url or id (use the flattened name for nested fields, for example author.id). Needed for Upsert and for skipping rows already in the sheet.

## `skipExistingKeys` (type: `boolean`):

In Append mode, don't add a row when a row with the same key columns is already in the tab (or earlier in this run). Skipped rows are not charged.

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

Only write these columns, in this order for a new tab. Leave empty to write every field. Columns already in the sheet keep their place; listed columns the sheet lacks are added at the end.

## `keepColumnOrder` (type: `boolean`):

In Replace mode, keep the tab's current header and column order (charts and formulas keep working); fields not in it are added at the end. Turn off to write a fresh header in the dataset's own order.

## `valueInputOption` (type: `string`):

Raw stores text exactly as it is. As typed lets Google turn text into numbers and dates as if you typed it in the sheet (formulas only if you allow them below). Raw is safer for keys and IDs.

## `allowFormulas` (type: `boolean`):

Only with 'As typed'. Off (safer): text starting with = is stored as text, so scraped data can't run formulas in your sheet. On: such text becomes a live formula.

## `flattenArrays` (type: `string`):

Nested objects always become columns such as author.name. For arrays: Join puts a list of plain values into one cell (a, b, c) and spreads lists of objects over numbered columns; JSON puts each array into one cell as JSON text; Numbered columns gives every element its own column (tags.0, tags.1).

## `arraySeparator` (type: `string`):

Text placed between joined array values.

## `nestedSeparator` (type: `string`):

Joins nested field names into one column name: author.name with a dot, author/name with a slash.

## `offset` (type: `integer`):

Start reading the dataset after this many items.

## `limit` (type: `integer`):

Read at most this many items from the dataset. 0 means all. The run's maximum cost is also respected.

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

Paste a Google service-account JSON key to write with your own service account instead of ours. Share the sheet with that account's email as Editor. No link code is needed then. Stored encrypted.

## `payload` (type: `object`):

Filled in by Apify when this Actor runs as an integration after another Actor's run. The triggering run's dataset is used when Dataset is empty.

## Actor input object example

```json
{
  "spreadsheet": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0",
  "sheetName": "Leads",
  "mode": "append",
  "keyColumns": [
    "url"
  ],
  "skipExistingKeys": false,
  "columns": [
    "title",
    "price",
    "url"
  ],
  "keepColumnOrder": true,
  "valueInputOption": "RAW",
  "allowFormulas": false,
  "flattenArrays": "join",
  "arraySeparator": ", ",
  "nestedSeparator": ".",
  "offset": 0,
  "limit": 0
}
```

# Actor output Schema

## `result` (type: `string`):

One row per run: status, plain-language message, rows appended, updated and skipped, columns added, and a link to the tab.

## `summary` (type: `string`):

JSON record with the result plus details: unknown input keys, warnings, Google API calls and retries, grid changes and options used.

# 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("rivetfinch/sheets-export").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("rivetfinch/sheets-export").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 rivetfinch/sheets-export --silent --output-dataset

```

## MCP server setup

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

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/ZpnIl8lPnNbfLXJVE/builds/dtc0DPKlWPJLCpjib/openapi.json
