Skip to main content

Collect API user data and store in Google Sheets with CSV backup

Workflow preview

Workflow preview
100%
Collect API user data and store in Google Sheets with CSV backup preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This n8n workflow automates the process of fetching user data from an API , verifying its validity, transforming the response, and then saving it to Google Sheets for team collaboration. Additional...

Best for

  • Engineering automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.httprequest, n8n-nodes-base.if, n8n-nodes-base.function, n8n-nodes-base.googlesheets, n8n-nodes-base.spreadsheetfile, n8n-nodes-base.stickynote, n8n-nodes-base.stopanderror

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by PrideVel.

Original n8n.io source

1.1 Workflow description

Title
Collect API user data and store in Google Sheets with CSV backup
Workflow name
Collect API user data and store in Google Sheets with CSV backup

🧾 Overview

This n8n workflow automates the process of fetching user data from an API, verifying its validity, transforming the response, and then saving it to Google Sheets for team collaboration. Additionally, it generates a CSV backup file of the same data for offline access or external integrations.

Perfect for developers, analysts, or teams who want an automated, no-code data ingestion and backup solution.


βš™οΈ Key Features

  • πŸ”Œ Fetches data from any REST API endpoint (e.g., RandomUser API)
  • βœ… Validates successful API responses before processing
  • 🧠 Transforms JSON response into simple key-value pairs (name and country)
  • πŸ“Š Appends data directly into Google Sheets
  • πŸ’Ύ Generates a downloadable CSV backup file
  • 🧱 Modular design β€” easily customizable and extendable

🧱 Workflow Steps

1. Start Workflow Manually (Manual Trigger Node)

The workflow starts manually by clicking Execute Workflow. You can later replace this with a Cron or Webhook trigger for automation.


2. Fetch User Data from API (HTTP Request Node)

Makes an HTTP GET request to the configured API endpoint defined in the environment variable BASE_URL.

Example:

https://randomuser.me/api/?results=10

This node fetches raw user data in JSON format.


3. Verify API Response Success (If Node)

Checks if the API response returned an HTTP 200 status code.

  • βœ… If status = 200 β†’ Continue processing data
  • ❌ If status β‰  200 β†’ Trigger Stop and Error node to halt execution

This prevents saving invalid or failed responses.


4. Transform API Data to Name and Country (Function Node)

Formats the raw JSON data to extract key details (name and country) from each user record.

Input Example:

{
  "results": [
    {
      "name": { "first": "John", "last": "Doe" },
      "location": { "country": "United States" }
    }
  ]
}

Output Example:

[
  { "name": "John Doe", "country": "United States" }
]

This step makes the data compatible with Google Sheets.


5. Append Data to Google Sheets (Google Sheets Node)

Appends the formatted data to your specified Google Sheet.

Environment Variables Required:

  • GOOGLE_SHEET_ID β†’ ID of your target Google Sheet

Configuration:

  • Range: A:B
  • Columns: Name (A) and Country (B)

Example Google Sheet:

Name Country
John Doe United States
Jane Smith Canada

6. Create CSV Backup File (Spreadsheet File Node)

Generates a .csv file named users_backup_export.csv containing all saved user data.

This file can be:

  • Stored locally
  • Sent via email
  • Uploaded to cloud storage (e.g., Google Drive, Dropbox)
  • Used for external analytics tools

⚠️ Error Handling

If the API response is invalid (non-200), the Stop on API Failure node halts the workflow and logs the error:

> ❌ API request failed β€” status code not 200. Workflow stopped.

This ensures only valid data is stored.


🧰 Setup Instructions

  1. Add Environment Variables:

    BASE_URL=https://randomuser.me/api/?results=10
    GOOGLE_SHEET_ID=<your_google_sheet_id>
    
  2. Add Credentials:

    • Google Sheets OAuth2 credentials
    • API (if authentication is required)
  3. Run Workflow:

    • Start manually or configure a Cron node to run periodically
  4. Check Output:

    • Data appears in your Google Sheet
    • CSV file is created in n8n’s file system

🧩 Customization Options

Goal How to Modify
Change API fields Edit Transform API Data function to extract desired fields
Add columns Expand output object and update Google Sheets range (e.g., A:D)
Automate execution Replace manual trigger with a Cron or Webhook node
Filter users Add an If node after transformation to include/exclude data
Send email notification Add Gmail or SMTP node after CSV creation

🧠 Example Use Case

  • A recruiter fetches random candidate data daily from an HR API.
  • Data (Name + Country) is saved to Google Sheets.
  • A CSV backup is automatically generated for offline analysis.

βœ… Benefits

  • Hands-free automated data collection
  • Centralized storage in Google Sheets for team access
  • Built-in CSV export for reporting and backups
  • Protects data integrity with API validation
  • Fully customizable for any API format

✨ Tip: Add a Slack or Telegram node at the end to notify your team whenever new data is added successfully!

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Start Workflow Manually

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Fetch User Data from API

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 2

Block 3 - Verify API Response Success

Type / Role
n8n-nodes-base.if - if
Config choices
Version 1

Block 4 - Transform API Data to Name and Country

Type / Role
n8n-nodes-base.function - function
Config choices
Version 1

Block 5 - Append Data to Google Sheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 1

Block 6 - Create CSV Backup File

Type / Role
n8n-nodes-base.spreadsheetFile - spreadsheetFile
Config choices
Version 1

Block 7 - Workflow Documentation

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Stop on API Failure

Type / Role
n8n-nodes-base.stopAndError - stopAndError
Config choices
Version 1

Block 9 - Step 1 - Trigger

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Step 2 - API Request

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Step 3 - Validation

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Step 4 - Transform

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Step 5 - Google Sheets

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Step 6 - CSV Backup

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Collect API user data and store in Google Sheets with CSV backup
Complexity intermediate
Nodes 14
Categories Engineering
Author PrideVel
Published 11 Nov 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/10725/10725.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Collect API user data and store in Google Sheets with CSV backup do?

This n8n workflow automates the process of fetching user data from an API , verifying its validity, transforming the response, and then saving it to Google Sheets for team collaboration. Additional...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.