Google Sheets Integration - Fast Import, Export & Upsert avatar

Google Sheets Integration - Fast Import, Export & Upsert

Pricing

$0.50 / 1,000 row synchronizeds

Go to Apify Store
Google Sheets Integration - Fast Import, Export & Upsert

Google Sheets Integration - Fast Import, Export & Upsert

Seamless bi-directional integration between Google Sheets and Apify. Export datasets to Google Sheets with smart flattening and key-based upserting; or import Google Sheets into Apify datasets with zero-auth public reading.

Pricing

$0.50 / 1,000 row synchronizeds

Rating

0.0

(0)

Developer

Vnx0

Vnx0

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

8 days ago

Last modified

Categories

Features

Limited permissions

Share

πŸ“Š Google Sheets Integration - Fast Bi-Directional Sync & Key UPSERT

The universal, bi-directional data bridge between Google Sheets and the Apify platform. Export any Apify scraper dataset into Google Sheets with smart nested JSON flattening, dynamic column reconciliation, and in-place key-based UPSERTβ€”or turn any Google Sheet into an automated zero-auth input feed in under 1 second without complex coding or $25/mo Zapier subscriptions.


⚑ TL;DR & Quick Summary

  • Bi-Directional Pipeline: Export Apify datasets to Google Sheets (APPEND, OVERWRITE, UPSERT) or import spreadsheet rows directly into typed Apify datasets.
  • Zero-Auth Public Reads: Stream rows from any public Google Sheet link in under 1 second without a Google Cloud account, API key, or OAuth setup.
  • Key-Based UPSERT Engine: Update existing rows by unique key (id, sku, url) in-place and append new rowsβ€”zero duplicate rows, zero broken formulas.
  • Smart Recursive JSON Flattener: Automatically unfolds nested scraper JSON (specs.dimensions.width) into dot-notated columnsβ€”never see [object Object] again.
  • Enterprise Safety & Reliability: Automatic 500-row batching, jittered exponential backoff for Google 60 req/min limits, 49,900-character cell truncation, and encrypted credentials (isSecret: true).
  • Transparent PPE Pricing: Just $0.0005 per row ($0.50 per 1,000 rows). Platform compute is 100% covered by the creator; you only pay for actual rows delivered.

🎯 What Can You Do With This Integration?

Connect any web scraper or dataset to Google Sheets with zero friction:

  • πŸ”„ Bi-Directional Flexibility: Switch between exporting scraped data to sheets or reading live spreadsheet rows into your Apify actors with a single dropdown.
  • πŸ”‘ Key-Based UPSERT: Match incoming records by primary key (asin, sku, email, url). Existing rows update cell values in-place (e.g. Row 42 updates price from $348 to $298), while newly discovered items append cleanly to the bottom.
  • 🧩 Smart JSON Flattening: Recursively unpacks deeply nested scraper objects into clean columns with custom delimiters (specs.color, pricing.retail_usd).
  • ⚑ Dynamic Column Reconciliation: When web scrapers discover new fields mid-crawl, new column headers are automatically created and aligned without corrupting existing rows.
  • 🎨 Professional Styling: Automatically freezes top header rows, applies bold styling, and sets auto-expanding column widths for presentation-ready sheets.
  • πŸ›‘οΈ Built-in Crash Protection: Enforces Google's strict 50,000-character cell ceiling by safely truncating oversized content at 49,900 characters with ... [TRUNCATED].

⚑ How to Sync in 3 Easy Steps

  1. Open the Actor: Sign up for a free Apify account (every account receives $5.00 free credits monthly).
  2. Choose Mode & Paste Target: Select IMPORT_FROM_SHEET (Read) or EXPORT_TO_SHEET (Write), then paste your Google Sheet URL.
  3. Click "Save & Start": Watch records stream in real time. For exports, open your Google Sheet to see rows formatted with frozen headers.
{
"mode": "IMPORT_FROM_SHEET",
"spreadsheet": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit",
"sheetName": "Class Data",
"publicSheet": true
}

πŸ₯Š Why This Actor Beats Alternatives

Legacy Google Sheets actors on Apify and third-party webhook tools suffer from frequent OAuth token expirations, 429 rate limit crashes, and mangled nested data:

CapabilityLegacy Apify Scrapers (lukaskrivka)Zapier / Make.comRaw Google Sheets APIGoogle Sheets Integration (This Actor)
Pipeline DirectionClunky read, rigid exportBi-directional (multi-step)Raw code requiredFull Bi-Directional (EXPORT_TO_SHEET & IMPORT_FROM_SHEET)
Deduplication / Upsert❌ None (Duplicates or full wipe)Complex search + update stepsManual row lookup logicβœ… Native Key-Based UPSERT (In-place cell update & net-new append)
Public Sheet Access❌ Requires Google Cloud credentials❌ Requires Google account login❌ Requires API keyβœ… Zero-Auth Instant Stream (Reads public links in <1s)
Header Drift Handling❌ Scrambles columns in append modeRigid schema matchingThrows on mismatched rangesβœ… Dynamic Reconciliation (Auto-maps and expands new columns)
Nested JSON Flattening❌ Mangled as [object Object]Requires JSON parse modulesManual string serializationβœ… Recursive Flattener (specs.color, pricing.retail)
Cell Overflow Protection❌ Crashes with HTTP 400 on >50k charsTruncates unpredictablyFails whole batchβœ… Safe Truncation (Auto-caps at 49,900 chars with ... [TRUNCATED])
Rate Limit Resilience❌ Frequent Google 429 quota locksThrottled / Slow executionRequires custom retry logicβœ… 500-Row Chunking + Jittered Exponential Backoff
Credential Security❌ Stored in plaintextEncrypted in third-party DBHandled by developerβœ… Encrypted at Rest (isSecret: true in Apify Key-Value Store)
Cost for 10,000 RowsHigh compute burn ($0.05 - $0.20+)$25.00+ in task quotasFree (with dev maintenance)$5.00 total ($0.50/1k rows, compute 100% covered)

πŸ’° Transparent Pay-Per-Event (PPE) Pricing

This Actor uses Apify's Pay-Per-Event (PPE) pricing model. You pay only for actual rows processed:

Rows SynchronizedActor Cost (USD)Effective RatePlatform Compute Surcharge
1,000 rows$0.50$0.0005 per row$0.00 (Covered by Creator)
5,000 rows$2.50$0.0005 per row$0.00 (Covered by Creator)
10,000 rows$5.00$0.0005 per row$0.00 (Covered by Creator)
50,000 rows$25.00$0.0005 per row$0.00 (Covered by Creator)
100,000 rows$50.00$0.0005 per row$0.00 (Covered by Creator)

πŸ’‘ Apify Monthly Free Tier: Every Apify account receives $5.00 of free platform credits every month, allowing you to synchronize up to 10,000 rows completely free each month.


πŸ’Ό High-Value Use Cases & Playbooks

1. πŸ›’ E-Commerce & Retail: Live Competitor Price Tracker

  • The Problem: Appending scraper runs to Google Sheets creates thousands of duplicate rows every day, breaking Looker Studio charts and formulas.
  • The Solution: Set Write Mode to UPSERT with upsertKey: "sku". As prices, stock status, or shipping costs fluctuate, the existing row updates in-place on row 42, while newly discovered items append cleanly to the bottom.

2. πŸ’Ό B2B Lead Generation: Enriched Sales Pipelines

  • The Problem: Sales teams need scraped leads from Google Maps, LinkedIn, or Apollo in their spreadsheet immediately, but scraping columns vary per lead.
  • The Solution: Dynamic Header Reconciliation detects new fields (e.g. instagram, direct_phone, employee_count) and automatically expands the sheet headers to the right, mapping every lead to the exact column.

3. πŸ€– AI & RAG Engineers: Google Sheets as an Actor Input Queue

  • The Problem: Non-technical team members need to manage URLs, keywords, or queries that scrapers consume without touching code or JSON inputs.
  • The Solution: Team members add target URLs to a Google Sheet. Schedule this Actor to run daily in IMPORT_FROM_SHEET mode, streaming rows into the default dataset which downstream scraping actors read as their startUrls.

4. πŸ“ˆ SEO & Growth Marketers: Daily SERP Tracking

  • The Problem: Need historical tracking of search engine result positions over months without manual copy-pasting.
  • The Solution: Wire a Google Search Scraper to this Actor via webhook in APPEND mode. Daily keyword rankings, snippet text, and URLs are logged with timestamps into clean chronological rows.

⚑ Production Use-Case Recipes (Copy-Paste JSON)

Recipe 1: Instant Public Sheet Import (Zero Setup)

Stream data from any public Google Sheet into an Apify dataset with zero authentication:

{
"mode": "IMPORT_FROM_SHEET",
"spreadsheet": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit",
"sheetName": "Class Data",
"publicSheet": true,
"inferTypes": true
}

Recipe 2: Export Apify Scraper Dataset (Append Mode)

Append new records from any scraper run to an existing Google Sheet:

{
"mode": "EXPORT_TO_SHEET",
"spreadsheet": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit",
"sheetName": "Scraped Leads",
"datasetId": "YOUR_DATASET_ID",
"writeMode": "APPEND",
"flattenNestedObjects": true,
"formatSheet": true,
"serviceAccountEmail": "my-service-account@project.iam.gserviceaccount.com",
"serviceAccountPrivateKey": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASC..."
}

Recipe 3: Key-Based UPSERT for Price Tracking

Update matching products by sku and append new items without creating duplicate rows:

{
"mode": "EXPORT_TO_SHEET",
"spreadsheet": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit",
"sheetName": "Live Catalog",
"datasetId": "YOUR_DATASET_ID",
"writeMode": "UPSERT",
"upsertKey": "sku",
"flattenNestedObjects": true,
"serviceAccountEmail": "my-service-account@project.iam.gserviceaccount.com",
"serviceAccountPrivateKey": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASC..."
}

Recipe 4: Overwrite Tab with Fresh Daily Snapshot

Completely refresh a spreadsheet tab with the latest dataset run using raw JSON credentials:

{
"mode": "EXPORT_TO_SHEET",
"spreadsheet": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit",
"sheetName": "Daily Snapshot",
"writeMode": "OVERWRITE",
"formatSheet": true,
"serviceAccountJson": "{\"type\":\"service_account\",\"project_id\":\"my-project\",\"private_key\":\"...\",\"client_email\":\"...\"}"
}

πŸ› οΈ Setting Up Google Service Account (2-Minute Guide)

Writing to private Google Sheets or running automated EXPORT and UPSERT operations requires a Google Cloud Service Account. Unlike OAuth tokens, service account keys never expire, making them the industry standard for unattended cloud automations.

  1. Create Project & Enable API:
    • Go to the Google Cloud Console.
    • Create a project (e.g. Apify Sheets Integration) and enable the Google Sheets API.
  2. Create Service Account:
    • Navigate to IAM & Admin > Service Accounts and click Create Service Account.
    • Give it a name (e.g. apify-sheets-sync) and click Done.
  3. Generate Key:
    • Click on your new service account, open the Keys tab, click Add Key > Create new key, and choose JSON.
    • Download the file to your computer.
  4. Share Your Spreadsheet:
    • Open your target Google Sheet.
    • Click the green Share button in the top right.
    • Paste the service account email (e.g. apify-sheets-sync@your-project.iam.gserviceaccount.com) and grant Editor access.
  5. Paste into Actor:
    • Paste the client_email and private_key into the Actor input (or paste the entire file into serviceAccountJson).

πŸ”— Automated Scraper Integration & Webhooks

You can configure any Apify web scraper (e.g. Google Maps Scraper, Amazon Scraper, Instagram Scraper) to automatically pipe its results into Google Sheets the second a run finishes.

Setup via Apify Console Webhook:

  1. Open your scraping Actor in the Apify Console.
  2. Navigate to the Integrations tab and click Add Webhook.
  3. Select event trigger: Run succeeded.
  4. Set Target URL to: https://api.apify.com/v2/acts/vnx0~google-sheets-integration/runs?token=YOUR_APIFY_TOKEN
  5. Set Payload template:
    {
    "mode": "EXPORT_TO_SHEET",
    "datasetId": "{{resource.defaultDatasetId}}",
    "spreadsheet": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit",
    "sheetName": "Scraped Records",
    "writeMode": "APPEND",
    "serviceAccountEmail": "@mySecretEmail",
    "serviceAccountPrivateKey": "@mySecretKey"
    }

Programmatic Invocation (Node.js & Python SDK):

JavaScript / TypeScript (apify-client):

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('vnx0/google-sheets-integration').call({
mode: 'EXPORT_TO_SHEET',
spreadsheet: 'https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit',
sheetName: 'Products',
writeMode: 'UPSERT',
upsertKey: 'sku',
serviceAccountEmail: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL,
serviceAccountPrivateKey: process.env.GOOGLE_SERVICE_ACCOUNT_KEY
});
console.log(`Export completed: ${run.id}`);

Python (apify-client):

from apify_client import ApifyClient
import os
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("vnx0/google-sheets-integration").call(run_input={
"mode": "IMPORT_FROM_SHEET",
"spreadsheet": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit",
"sheetName": "Class Data",
"publicSheet": True
})
# Stream dataset items into your Python pipeline
dataset_items = client.dataset(run["defaultDatasetId"]).list_items().items
print(f"Imported {len(dataset_items)} rows")

πŸ“₯ Input Parameters Dictionary

ParameterTypeDefaultDescription
modeString"IMPORT_FROM_SHEET"Operation direction: IMPORT_FROM_SHEET (Read to dataset) or EXPORT_TO_SHEET (Write to sheet).
spreadsheetStringPre-filledFull Google Sheets URL or bare Spreadsheet ID.
sheetNameString"Sheet1"Name of the sheet tab. Automatically created if missing during export.
publicSheetBooleantrueSet to true to stream public sheets ("Anyone with the link can view") without credentials.
serviceAccountEmailString""Google Cloud Service Account email (required for private sheets and writes).
serviceAccountPrivateKeyString""Google Cloud Service Account private key string (encrypted at rest with isSecret: true).
serviceAccountJsonString""Alternative to fields above: paste entire service account JSON file (encrypted at rest with isSecret: true).
datasetIdString""Apify Dataset ID to export. If left blank, automatically uses the most recent actor run.
writeModeString"APPEND"Write strategy: APPEND (add below), OVERWRITE (replace tab), or UPSERT (update by key).
upsertKeyString"id"Unique identifier column name used to match rows during UPSERT mode (e.g. sku, url).
fieldsArray[]List of specific column names to export. Leave empty to automatically export all fields.
flattenNestedObjectsBooleantrueRecursively flattens nested objects into dot-notated columns (address.city).
flattenDelimiterString"."Delimiter character used to join nested object property keys.
formatSheetBooleantrueFreezes top header row, styles headers with bold text, and sets clean cell alignment.
headerRowIndexInteger1Row number containing column headers for import (1-indexed).
inferTypesBooleantrueAutomatically parses numeric strings, booleans, and ISO dates into typed JSON values.
maxRowsInteger10000Safety limit to prevent runaway memory or quota consumption.
batchSizeInteger500Batch chunk size per Google Sheets API request (optimized for throughput and rate limits).

πŸ“€ Output Structure & Console Views

1. Dual-Layer Dataset Records (Import Mode)

Imported rows emit dual-layer records: flat root attributes populate the Apify Console web table view immediately on Page 1, while complete raw payloads remain accessible under _rawData for downstream programmatic workflows:

{
"Student Name": "Alexandra",
"Gender": "Female",
"Class Level": "4. Senior",
"Home State": "CA",
"Major": "English",
"Extracurricular Activity": "Drama Club",
"_rowNumber": 2,
"_sheetName": "Class Data",
"_spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit",
"_spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"_rawData": {
"Student Name": "Alexandra",
"Gender": "Female",
"Class Level": "4. Senior",
"Home State": "CA",
"Major": "English",
"Extracurricular Activity": "Drama Club"
}
}

2. Execution Telemetry Artifact (OUTPUT)

Every export or import run saves a detailed telemetry summary under the OUTPUT key in the default Key-Value Store:

{
"status": "SUCCESS",
"mode": "EXPORT_TO_SHEET",
"writeMode": "UPSERT",
"spreadsheetId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit",
"sheetName": "Live Catalog",
"rowsProcessed": 500,
"rowsAppended": 420,
"rowsUpdated": 80,
"columnsCount": 16,
"durationMs": 2450,
"timestamp": "2026-11-17T01:30:00.000Z"
}

πŸ›‘οΈ Enterprise Reliability & Anti-Crash Architecture

  • Google API Rate Limit Resilience (60 req/min): Google limits writes to 60 requests per minute per user. This Actor batches operations into optimized 500-row chunks. A 10,000-row dataset writes in just 20 requests. If Google temporarily throttles requests with HTTP 429, the Actor automatically recovers using jittered exponential backoff.
  • Safe Cell Boundary Guard (49,900 Chars): Google Sheets strictly rejects any cell containing more than 50,000 characters with an INVALID_ARGUMENT fatal error. Web scrapers frequently extract long article texts, HTML blobs, or logs that exceed this threshold. This Actor monitors string lengths and automatically truncates oversized content at 49,900 characters with a clean ... [TRUNCATED] suffix.
  • Formula Injection Safeguard: To prevent spreadsheet formula injection vulnerabilities, any string beginning with =, +, -, or @ is sanitized so spreadsheet software treats it as plain text rather than executing arbitrary macros.
  • Credential Encryption at Rest (isSecret: true): All private keys and service account JSONs are encrypted at rest with Apify's public key encryption, preventing credentials from leaking in Key-Value Store records or web interfaces.

❓ Frequently Asked Questions (FAQ)

Can I read a Google Sheet without setting up a Google Cloud project?

Yes! If your sheet is shared with "Anyone with the link can view", leave publicSheet: true enabled and paste the URL. The Actor uses zero-auth streaming CSV parsing to import rows directly into your dataset without any Google credentials.

How does UPSERT matching work?

In UPSERT mode, the Actor inspects the column matching your upsertKey (e.g. id, sku, url). It indexes existing row values, compares each incoming dataset record, updates matching rows in-place, and appends net-new records to the bottom.

What happens if incoming records have different or new columns?

The Actor implements Dynamic Header Reconciliation. In APPEND and UPSERT modes, existing columns are preserved. If a new field appears in your dataset (e.g. author.twitter), a new header column is automatically appended to the right and populated.

Why do you use Service Accounts instead of OAuth?

Google OAuth tokens expire after 1 hour or require manual re-authentication prompts, causing automated nightly scraper runs to fail. Google Cloud Service Accounts use cryptographic key pairs that never expire, ensuring 100% reliable 24/7 background automation.

Are my service account credentials safe?

Yes. Both serviceAccountPrivateKey and serviceAccountJson are marked with "isSecret": true in the Actor's input schema. Apify automatically encrypts them at rest in the default Key-Value Store (INPUT), ensuring they are never exposed to viewers or third parties.

How does pricing work?

This Actor uses Apify's Pay-Per-Event (PPE) pricing at $0.0005 per row processed ($0.50 per 1,000 rows). Platform compute is covered by the creator, meaning you never pay compute surcharges for idle waiting or rate-limit backoffs.


Google Sheets Integration is an automated bridge tool designed for processing user-authorized datasets and spreadsheets.

  • It does not store user data beyond the temporary lifecycle of your Apify run.
  • All communications with Google Sheets API v4 occur over encrypted HTTPS connections using Google's official client libraries.
  • Users are responsible for complying with the Apify Terms of Service and Google API Services User Data Policy.