Carabain Digital Apify Actors

Google Sheets Export

Google Sheets Export writes any Apify dataset into a tab of a Google Sheet, with a header row and nested fields flattened into columns. It can replace the tab, append below it, or add only rows whose key is not in the sheet yet, so scheduled scrapers feed one growing sheet without duplicates.

Run it on ApifyCreate a free Apify account

The Apify Free plan includes $5 of credit every month, no credit card needed.

One exported row in your dataset
sheet
Spreadsheet and tab the row was written to
row
The row as written, column name to cell value
exportedAt
Export time, ISO 8601 UTC

and 1 more fields, see Output

Who it is for

Teams that run scrapers on Apify but work in Google Sheets: sales teams with lead lists, marketers with price or rank trackers, analysts who build Looker Studio reports. Also developers who want a reliable last step after a scraper run instead of their own Sheets API code.

What you can do with the data

A lead list that only grows

Connect it to a scheduled scraper and pick appendNew with keyField set to url. Each run adds only leads the sheet has not seen, so the sales team works one list without the same lead twice.

A fresh price table for charts

Use replace to clear the tab and write the newest results after every run. Keep your charts and formulas on another tab that reads from it, since a replace overwrites edits in the target tab.

Only the columns your team reads

List fields in fields to set the columns and their order, with dot paths such as address.city for nested data. Fields you leave out of the list are not written.

A source for Looker Studio or Apps Script

The sheet becomes the data source for a dashboard or a script. Values are written as raw text by default, so a scraped string that starts with = stays text and cannot run as a formula.

Tutorial

How to send new scraper results to a sheet after every run

  1. Get a free Apify account and click the Run it on Apify button on this page to open the Actor.
  2. Create a Google spreadsheet and share it as Editor with the built-in service account, sheets-export@apify-514417.iam.gserviceaccount.com, or paste your own key into serviceAccountJson.
  3. Open the scraper you want to export, go to its Integrations tab and add Google Sheets Export.
  4. Set datasetId to {{resource.defaultDatasetId}} and paste the sheet URL into spreadsheet. Choose a tab in sheetName, such as Leads.
  5. Set mode to appendNew and keyField to a unique field of your data, such as url or id.
  6. Run the scraper. When it finishes, the export runs and the status message says how many rows were added.

Examples

Export a dataset to Google Sheets

Copies every item of an Apify dataset into a tab of your Google Sheet, with a header row and nested data flattened into columns. Replaces the tab on each run, so it is always a fresh copy. Replace the example dataset and spreadsheet with your own.

{
  "datasetId": "MYsSEJZcfvwhcDzhC",
  "spreadsheet": "https://docs.google.com/spreadsheets/d/1dHj8fy3dQYtPf37NiTl1qj-YqwCzb3jcNLrkpzqIYRI/edit",
  "sheetName": "Sheet1",
  "mode": "replace"
}
Run this input from the Apify API (curl)
curl -X POST 'https://api.apify.com/v2/acts/carabain-digital~google-sheets-export/run-sync-get-dataset-items' \
  -H "Authorization: Bearer $APIFY_TOKEN" -H 'Content-Type: application/json' \
  -d '{"datasetId": "MYsSEJZcfvwhcDzhC", "spreadsheet": "https://docs.google.com/spreadsheets/d/1dHj8fy3dQYtPf37NiTl1qj-YqwCzb3jcNLrkpzqIYRI/edit", "sheetName": "Sheet1", "mode": "replace"}'
Run it from Python
# pip install apify-client
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("carabain-digital/google-sheets-export").call(run_input={'datasetId': 'MYsSEJZcfvwhcDzhC', 'spreadsheet': 'https://docs.google.com/spreadsheets/d/1dHj8fy3dQYtPf37NiTl1qj-YqwCzb3jcNLrkpzqIYRI/edit', 'sheetName': 'Sheet1', 'mode': 'replace'})
items = client.dataset(run["defaultDatasetId"]).list_items().items

Append only new items to a Google Sheet

Adds only the dataset items whose url is not in your Google Sheet yet, so a scheduled scraper builds up a list without duplicates. Change the key field to any unique field of your data. Replace the example dataset and spreadsheet with your own.

{
  "datasetId": "MYsSEJZcfvwhcDzhC",
  "spreadsheet": "https://docs.google.com/spreadsheets/d/1dHj8fy3dQYtPf37NiTl1qj-YqwCzb3jcNLrkpzqIYRI/edit",
  "sheetName": "Items",
  "mode": "appendNew",
  "keyField": "url"
}
Run this input from the Apify API (curl)
curl -X POST 'https://api.apify.com/v2/acts/carabain-digital~google-sheets-export/run-sync-get-dataset-items' \
  -H "Authorization: Bearer $APIFY_TOKEN" -H 'Content-Type: application/json' \
  -d '{"datasetId": "MYsSEJZcfvwhcDzhC", "spreadsheet": "https://docs.google.com/spreadsheets/d/1dHj8fy3dQYtPf37NiTl1qj-YqwCzb3jcNLrkpzqIYRI/edit", "sheetName": "Items", "mode": "appendNew", "keyField": "url"}'
Run it from Python
# pip install apify-client
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("carabain-digital/google-sheets-export").call(run_input={'datasetId': 'MYsSEJZcfvwhcDzhC', 'spreadsheet': 'https://docs.google.com/spreadsheets/d/1dHj8fy3dQYtPf37NiTl1qj-YqwCzb3jcNLrkpzqIYRI/edit', 'sheetName': 'Items', 'mode': 'appendNew', 'keyField': 'url'})
items = client.dataset(run["defaultDatasetId"]).list_items().items

Set APIFY_TOKEN to your token from Apify Console, Settings, Integrations. The curl call waits up to 5 minutes; for bigger runs see running from the API and Python. AI agents can call it through the Apify MCP server: https://mcp.apify.com/?actors=carabain-digital/google-sheets-export.

Input

FieldTypeWhat it does
datasetId
Dataset
stringID, name or URL of the dataset to export (Storage > Datasets in the Console). As an integration of another Actor (Integrations tab), set it to {{resource.defaultDatasetId}} to export that run's results. Example: WkzbQMuFYuamGv3YF.
spreadsheet
Google spreadsheet
stringURL of the spreadsheet, or its ID (the part after /spreadsheets/d/). Share it with the service account as Editor first, see the Actor's README. Example: https://docs.google.com/spreadsheets/d/1AbC.../edit.
sheetName
Sheet (tab) name
stringThe tab to write to. It is created when it does not exist. Example: Leads.
Default: "Sheet1"
mode
Mode
stringReplace gives you a fresh copy every run. Append keeps the header of the sheet and adds new fields as new columns at the end. Append new skips rows already in the sheet: use it for scheduled runs.
Values: replace, append, appendNew
Default: "replace"
keyField
Key field (for Append new)
stringThe dataset field that identifies a row, compared with the same column in the sheet. Required for Append new, ignored otherwise. Example: url or id.
fields
Fields (columns)
arrayOnly these fields become columns, in this order. Use dot paths for nested fields. Empty = all fields, in the order they first appear. Example: name, rating, address.city.
flatten
Flatten nested data
booleanNested objects become columns named with a dot path (address.city), lists of plain values become a, b, and lists of objects become a JSON text in one cell. Off = every object or list is a JSON text.
Default: true
maxRows
Max rows
integerExport at most this many items, from the start of the dataset. Empty = all. Example: 1000.
valueInputOption
Cell values
stringRaw never turns text into formulas, so scraped text cannot run a formula in your sheet. Choose User entered only for data you trust.
Values: RAW, USER_ENTERED
Default: "RAW"
serviceAccountJson
Your own service account key (optional)
stringThe whole JSON key of a Google Cloud service account that has the Google Sheets API enabled and edit access to the spreadsheet. Stored encrypted. Empty = the built-in service account.

Output

One dataset item per exported row. Export the dataset as JSON, CSV, Excel or XML from Apify Console or the API.

FieldTypeDescription
sheetstringSpreadsheet and tab the row was written to
modestringWrite mode: replace, append or appendNew
rowobjectThe row as written, column name to cell value
exportedAtstringExport time, ISO 8601 UTC

Frequently asked questions

What does exporting 50,000 rows cost?

You pay $0.30 per 1,000 rows written to the sheet, so 50,000 rows cost about $15. Rows that were skipped or not written are not charged. A daily run that appends 200 new rows costs about $1.80 over 30 days.

Do I have to share my spreadsheet with your service account?

With the built-in account, yes: share the sheet with it as Editor, and it only writes to the spreadsheet you name. To avoid that, create a service account in Google Cloud with the Sheets API on and paste its JSON key into serviceAccountJson. It is stored encrypted.

How does Append new decide what is new?

It compares keyField in each dataset item with the same column in the sheet, as text. A row whose key is already there is skipped and not charged. Pick a field that never changes for an item, such as url or id.

What happens to nested objects and lists?

With flatten on, an object becomes columns such as address.city, and a list of plain values becomes one cell like a, b. Lists of objects are written as JSON text in one cell. With flatten off, every object or list is JSON text.

What are the limits of a Google Sheet?

A spreadsheet holds at most 10 million cells, and one cell at most 50,000 characters. An export too big for the file stops early with an explanation, and text over the cell limit is shortened. When Google's write quota is reached, it waits and retries. Use maxRows to cap one export.

Why did my run fail with a 403 error?

The spreadsheet is not shared with the service account as Editor. The status message names the email to share with. Share the sheet and run again.

Is it legal to export scraped data to Google Sheets?

The Actor copies a dataset from your account to a spreadsheet you control. If the rows hold data about people, such as names or emails, that is personal data under rules such as the GDPR, so limit who can open the sheet and check your use case with a lawyer. See Is web scraping legal?