# Google Sheets Import & Export: Datasets to Sheets and Back (`transparent_meteorite/google-sheets-import-export`) Actor

Import any Google Sheet into a dataset (public link, no login) or export an Apify dataset to a sheet: append or replace, one row per record. Service account or token.

- **URL**: https://apify.com/transparent_meteorite/google-sheets-import-export.md
- **Developed by:** [Detroit Web Agent - Open Data](https://apify.com/transparent_meteorite) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.54 / 1,000 sheet row processeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Import & Export: Datasets to Sheets and Back

Google Sheets import and export for Apify in one Actor. **Import** any Google Sheet into a dataset, one row per sheet row, with no login for sheets shared by link. **Export** any Apify dataset into a sheet, appending below existing rows or replacing the tab, with columns matched by header name. Every row comes back with the spreadsheet ID, tab, sheet row number and range, so you always know exactly what was read or written.

It talks to the Google Sheets endpoints directly over HTTP, so there is no browser, no proxy and no per-run setup. Public sheets need no credentials at all. Private sheets and every export use a service account key or an OAuth access token that you paste into a secret field.

### Run in 30 seconds

1. Open the **Input** tab. The prefilled link is a public sample sheet with 30 student rows.
2. Click **Start**. The run takes a few seconds.
3. Open the **Rows** table in the Output tab, or export the dataset as JSON, CSV or Excel.
4. Paste your own sheet link and run again. Set **Mode** to **Export** and add a dataset ID to write data into a sheet instead.

### What does this Actor do?

Two jobs, one input form.

**Import (sheet to dataset).** Give it a Google Sheets link or ID. It reads the tab you choose (the first tab by default, or the tab named in the `#gid=` part of the link), uses row 1 as field names and returns every following row as one dataset item. Numbers, TRUE and FALSE become real numbers and booleans, empty cells become `null`, and text such as `007` stays text. You can limit the read to an A1 range like `A1:F100`.

**Export (dataset to sheet).** Give it the ID of any Apify dataset, for example the default dataset of another Actor run, plus a spreadsheet and tab. It flattens each item, writes a header row if the tab is empty, and writes the rows in chunks. In **append** mode, new rows go under the existing data and fields are matched to the existing header names, with new fields added as extra columns on the right. In **replace** mode the tab is cleared first. A tab that does not exist is created for you.

Both modes return one dataset row per sheet row processed, with the same fields, so you can chain them in schedules, webhooks, n8n, Make or Zapier.

### What you get

| Field | Meaning |
|---|---|
| `spreadsheetId` | The Google spreadsheet ID |
| `spreadsheetTitle` | Spreadsheet title (filled when credentials are used, otherwise `null`) |
| `sheet` | Tab name |
| `mode` | `import` or `export` |
| `range` | The A1 range read or written, for example `'Class Data'!A1:F31` |
| `rowNumber` | The row number in the sheet |
| `rowsRead` | Total rows read in this run (import) or taken from the dataset (export) |
| `rowsWritten` | Rows written so far (export), `null` on import |
| `cellCount` | Number of filled cells in the row |
| `columnCount` | Number of columns in the row |
| `changeStatus` | `new`, `changed` or `unchanged` compared with the previous run (import with change tracking), otherwise `null` |
| `rowHash` | Short fingerprint of the row content (import), `null` on export |
| `data` | The row as an object: header name to cell value |
| `scrapedAt` | When the row was processed |

A run summary with the same counters, the list of tabs found and any warnings is stored in the **OUTPUT** key-value record.

### What you get that other Sheets Actors do not describe: change tracking on import

Other Google Sheets Actors on the Store (for example lukaskrivka/google-sheets, bridgeworks/sheets-bridge, s_actors/google-sheets-import-export) write data into sheets, and some update only the rows that changed on export. Their listings do not describe the other direction: telling you which sheet rows changed since the last run. This Actor does that on import.

Switch on **Track changes** and every row comes back with `changeStatus` (`new`, `changed` or `unchanged`) and a `rowHash`. Add a **Key column** such as `id` and the comparison follows the row, not its position, so sorting or inserting rows does not flag everything. Switch on **Return only new and changed rows** and a scheduled run returns only what moved, which is what you feed to n8n, Make or Zapier. The run summary in OUTPUT also holds `rowsNew`, `rowsChanged`, `rowsUnchanged` and `rowsRemoved`.

The previous state is a small record of row fingerprints (not your cell values) in a key-value store named `sheets-import-row-state` in your own Apify account. The first run has nothing to compare with, so every row is `new`. Changing the tab, range or key column starts a new baseline.

### Limits

- Import without credentials works only on sheets shared as **Anyone with the link: Viewer**. Otherwise the run ends with a clear message telling you to share the sheet or add credentials.
- Export always needs write access: a service account added to the sheet as **Editor**, or an OAuth access token with the spreadsheets scope. Access tokens last about an hour.
- Google allows about 10 million cells per spreadsheet and 50,000 characters per cell. Longer text is cut at 49,000 characters.
- Up to 200,000 rows per run. Large exports are written in chunks of up to 2,000 rows.
- Formulas are not evaluated on import: you get the displayed value of each cell. On export values are written as given unless you switch on **Interpret formulas and dates**.

### Input

| Field | What it does |
|---|---|
| **Mode** | `import` (sheet to dataset) or `export` (dataset to sheet) |
| **Spreadsheet link or ID** | Full URL or the ID between `/d/` and `/edit`. `#gid=123` selects a tab |
| **Tab name** | Tab to read or write. Empty means the first tab |
| **Range (import)** | Optional A1 range such as `A1:F100` or `B2:D` |
| **Max rows** | Import: stop after this many rows. Export: write at most this many dataset items |
| **First row is a header** | On: row 1 gives the field names. Off: fields are named A, B, C |
| **Convert numbers and booleans** | Turns `42`, `3.5`, `TRUE` into real types |
| **Skip empty rows** | Leaves out rows where every cell is empty |
| **Track changes** | Import only. Marks each row new, changed or unchanged since the previous run |
| **Return only new and changed rows** | Import only. Skips unchanged rows, so a schedule only pays for what moved |
| **Key column** | Import only. Header that identifies a row (for example `id`), so sorting or inserting rows is not read as a change |
| **Dataset ID or URL** | Export only: the dataset to write |
| **Write mode** | Export only: `append` or `replace` |
| **Columns** | Export only: fields to write, in order. Nested fields use dots like `address.city` |
| **Create the tab if missing** | Export only |
| **Interpret formulas and dates** | Export only. Off by default, which is the safe choice for untrusted text |
| **Service account JSON** | Secret. The full key file of a Google service account |
| **OAuth access token** | Secret. Alternative to the service account |

### Example input: import a public sheet

```json
{
  "mode": "import",
  "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0",
  "maxRows": 100
}
```

### Example input: export a dataset to a sheet

```json
{
  "mode": "export",
  "spreadsheetUrl": "YOUR_SPREADSHEET_ID",
  "sheetName": "Leads",
  "datasetId": "YOUR_DATASET_ID",
  "writeMode": "append",
  "columns": ["name", "website", "address.city"],
  "serviceAccountJson": "{ ...full key file... }"
}
```

### Output sample (import)

```json
{
  "spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
  "spreadsheetTitle": null,
  "sheet": "Class Data",
  "mode": "import",
  "range": "'Class Data'!A1:F31",
  "rowNumber": 2,
  "rowsRead": 30,
  "rowsWritten": null,
  "data": {
    "Student Name": "Alexandra",
    "Gender": "Female",
    "Class Level": "4. Senior",
    "Home State": "CA",
    "Major": "English",
    "Extracurricular Activity": "Drama Club"
  },
  "scrapedAt": "2026-11-16T14:42:27.638Z"
}
```

### How to set up a service account (about 3 minutes, once)

1. In the Google Cloud console create a project and enable the **Google Sheets API**.
2. Create a **service account**, then add a **JSON key** and download it.
3. Open your spreadsheet, click **Share**, and add the service account's `client_email` address as **Editor** (Viewer is enough for import).
4. Paste the whole JSON file into the **Service account JSON** field. It is a secret field, so Apify stores it encrypted and the Actor never prints it.

The service account can only see the sheets you shared with it. Nothing else in your Google account is reachable.

### Use cases

- **Feed a sheet from any scraper.** Run a scraper, then export its dataset to a Leads tab every morning. Append mode keeps history and matches the existing columns.
- **Use a sheet as a control panel.** Keep keywords, URLs or SKUs in a sheet, import them on a schedule and pass them to other Actors.
- **Backups and snapshots.** Import a team sheet into a dataset daily and keep a versioned copy.
- **Reporting.** Replace a dashboard tab with fresh numbers after each run.
- **Data hand-off.** Give non-technical teammates a sheet instead of a JSON file.

### Pricing

Pay per event, no subscription. Current prices:

| Event | Free | Bronze | Silver | Gold | Platinum | Diamond |
|---|---|---|---|---|---|---|
| Actor Start | $0.00005 | $0.00005 | $0.00005 | $0.00005 | $0.00005 | $0.00005 |
| Sheet row processed | $0.0009 | $0.00084 | $0.00072 | $0.00054 | $0.00054 | $0.00054 |

Tier follows your Apify subscription plan.

Apify's free plan includes monthly platform credit that covers test runs.

Examples at the current price (one `row` event per result; Free-plan tier):

| You pull | You pay |
|---|---|
| 100 results | $0.09 |
| 1,000 results | $0.90 |
| 10,000 results | $9.00 |

Scheduled runs stay cheap when each run only returns new records.

### Integrations and scheduling

Schedule the Actor from the Apify console, then connect it with webhooks, Make, Zapier or n8n. A common setup is a webhook on your scraper's "run succeeded" event that starts this Actor in export mode with the run's default dataset ID. You can also call it through the REST API and the Python and JavaScript clients.

### Use with the API, n8n, Make, Zapier or AI agents

**API** (one call, returns the rows as JSON):

```bash
curl -X POST "https://api.apify.com/v2/acts/transparent_meteorite~google-sheets-import-export/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN"   -H "Content-Type: application/json"   -d '{"mode":"import","spreadsheetUrl":"1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms","maxRows":100}'
```

**Python**

```python
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("transparent_meteorite/google-sheets-import-export").call(run_input={
    "mode": "import",
    "spreadsheetUrl": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
    "maxRows": 100,
})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["rowNumber"], row["data"])
```

- **n8n, Make, Zapier:** use the Apify app's "Run Actor" step with actor `transparent_meteorite/google-sheets-import-export`, paste the input JSON and map `data` to your next step.
- **AI agents (MCP):** connect the Apify MCP server at `https://mcp.apify.com?tools=transparent_meteorite/google-sheets-import-export` to Claude, Cursor or any MCP client, and your agent can read or write sheets as a tool.

### Security and fair use

Credentials go in secret input fields, are used only to call Google, and are never written to logs, the dataset or the OUTPUT record. Use a dedicated service account that has access only to the sheets you need. Exports are written as raw values by default, so text that starts with `=` is not executed as a formula. Only read sheets you own or have permission to read. This is an independent tool and is not affiliated with Google.

### FAQ

**Do I need a Google login or API key to import?** No, as long as the sheet is shared as "Anyone with the link". For private sheets add a service account or token.

**Can it export without credentials?** No. Google only allows writes from an authenticated account, so export needs a service account or access token.

**Which tab is read?** The tab selected by **Tab name**, otherwise the `#gid=` in your link, otherwise the first tab.

**Will formulas be kept?** Import returns the value shown in each cell. Export writes values only, unless you switch on **Interpret formulas and dates**.

**What happens to nested JSON in a dataset?** Nested objects are flattened into dotted columns like `address.city`. Arrays are written as JSON text in one cell.

**What if my header row has duplicates or blanks?** Duplicates get a numeric suffix (`name`, `name_2`) and blank headers become `column3` and so on.

**Why did my run end with a message and no rows?** Bad input, such as a private sheet without credentials or an unknown tab name, finishes as a normal run with the reason in the status message and the OUTPUT record, and nothing is charged.

**Is there a size limit?** Up to 200,000 rows per run; split larger jobs with the range option.

### Support

Found a sheet that reads or writes badly? Open an issue on the Issues tab with the run URL. Never paste a key into an issue.

### Related actors

New to Apify? [Create a free account](https://console.apify.com/sign-up) and run this Actor in under a minute.

- [Website Email Extractor](https://apify.com/transparent_meteorite/website-contact-extractor) for emails and contact details to put into your sheet.
- [Company Enrichment by Domain](https://apify.com/transparent_meteorite/company-enrichment-by-domain) to enrich a column of domains before you export.
- [Local Business Leads](https://apify.com/transparent_meteorite/local-business-leads) to fill a leads tab with fresh local businesses.

### Changelog

- **0.2**: Change tracking on import (`changeStatus`, `rowHash`, key column, only-changed mode) and `cellCount` / `columnCount` on every row.
- **0.1**: First private build. Import by link or API, export with append or replace, header matching, row numbers, deadline and cost guards.

# Actor input Schema

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

Import reads a Google Sheet and returns one dataset row per sheet row. Export writes an Apify dataset into a sheet.

## `spreadsheetUrl` (type: `string`):

The full Google Sheets URL, or just the ID between /d/ and /edit. A #gid=123 at the end selects that tab.

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

Tab to read or write. Import: first tab if empty. Export: first tab if empty; a missing tab is created.

## `range` (type: `string`):

Optional A1 range to read, for example A1:F100 or B2:D. Empty reads the whole tab.

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

Import: stop after this many data rows. Export: write at most this many dataset items.

## `hasHeader` (type: `boolean`):

Import: use row 1 as field names. If off, fields are named A, B, C.

## `convertTypes` (type: `boolean`):

Import: turn 42, 3.5, TRUE and FALSE into real numbers and booleans. Text such as 007 stays text. Empty cells become null.

## `skipEmptyRows` (type: `boolean`):

Import: leave out rows where every cell is empty.

## `trackChanges` (type: `boolean`):

Marks every row as new, changed or unchanged compared with the previous run on the same sheet, tab and range. The baseline is kept in a key-value store named sheets-import-row-state in your account.

## `onlyChanged` (type: `boolean`):

Skips rows that did not change since the last run. Turns on change tracking. Rows are charged only when returned.

## `keyColumn` (type: `string`):

Column header that identifies a row, for example id or email. With a key, inserting or sorting rows does not mark everything as changed. Empty means rows are matched by row number.

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

Export only: the Apify dataset to write, for example the default dataset of another run. It must belong to your account.

## `writeMode` (type: `string`):

Append adds rows under the existing data and matches columns by header name. Replace clears the tab first.

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

Optional list of dataset fields to write, in this order. Nested fields use dots, like address.city. Empty writes every field.

## `createSheetIfMissing` (type: `boolean`):

Export: add the tab when it does not exist.

## `interpretFormulas` (type: `boolean`):

Off writes values exactly as given (safe). On lets Sheets parse values like =SUM(A1:A3) and 2026-11-16, which also lets untrusted text run as a formula.

## `serviceAccountJson` (type: `string`):

Paste the full key file of a Google service account. Share the sheet with its client_email (Viewer to import private sheets, Editor to export). Stored encrypted and never printed.

## `accessToken` (type: `string`):

Alternative to a service account: a Google OAuth access token with the spreadsheets scope. Tokens expire after about an hour.

## Actor input object example

```json
{
  "mode": "import",
  "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0",
  "maxRows": 100,
  "hasHeader": true,
  "convertTypes": true,
  "skipEmptyRows": true,
  "trackChanges": false,
  "onlyChanged": false,
  "writeMode": "append",
  "createSheetIfMissing": true,
  "interpretFormulas": false
}
```

# Actor output Schema

## `rows` (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 = {
    "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0",
    "maxRows": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("transparent_meteorite/google-sheets-import-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 = {
    "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0",
    "maxRows": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("transparent_meteorite/google-sheets-import-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 '{
  "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0",
  "maxRows": 100
}' |
apify call transparent_meteorite/google-sheets-import-export --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,transparent_meteorite/google-sheets-import-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/Ub6VYKZYAFkk3qNIs/builds/C6ishgGuF3mkRve02/openapi.json
