How to Track Trending Topics in Google Sheets Automatically
Build a reproducible pipeline that appends live trending topics into Google Sheets: fetch via API, append with the Sheets API, dedupe, schedule, troubleshoot.

You can track trending topics in Google Sheets automatically by pulling trend rows from a trend API and appending them with the Google Sheets API. The Sheet becomes a timestamped log — keyword, volume, category, and when the trend was first seen — that refreshes on a schedule instead of being copied by hand.
The approach below uses TrendsAGI as the trend source and Google Sheets as the destination. Google's own documentation describes Sheets as a real-time, collaborative spreadsheet editor available on web, Android and iOS (Google Workspace), and the Sheets API as a RESTful interface for reading and modifying spreadsheet data — creating spreadsheets, reading and writing cell values, updating formatting and managing sheets (Google for Developers). That is all you need: one call to fetch trends, one call to append them.
Why not scrape Google Trends into a Sheet?
Most recipes for this job rely on the Google Trends RSS feed or a scraper. Both are fragile: feed freshness and geographic coverage are not documented in a way you can depend on, scrapers get rate-limited, and a failed request often writes blank rows rather than failing loudly. There is no official Google Trends API listed in the sources reviewed here, so treat any claim of stable programmatic access to Trends as unconfirmed.
A trend-intelligence API gives you a documented response shape, measured velocity (posts per hour from stored snapshots), AI-written summaries and themes, and error responses you can actually handle. Velocity is a measured snapshot rate, not a forecast or unique-user count — worth stating in your sheet header so nobody misreads the column.
Prepare the destination sheet
- Create a spreadsheet and add a sheet titled
Trends. - In row 1, add headers:
Fetched At,Trend ID,Name,Category,Velocity,Growth,Volume,Summary. - Copy the spreadsheet ID from the URL. Per Google for Developers, a spreadsheet is identified by a unique
spreadsheetIdderived from the URL, and it does not change when you rename the file. - Enable the Google Sheets API in a Google Cloud project and create a service account. Share the spreadsheet with the service account's email as an editor.
Ranges use A1 notation, for example Trends!A:H for the whole block or 'Trends Log'!A:H when the sheet name contains a space — Google for Developers notes that names with spaces or special characters must be wrapped in single quotes inside the range string.
Step 1: Fetch trends with the TrendsAGI REST API
Authenticate with the X-API-Key header and read the key from an environment variable. Sort by velocity to surface what is accelerating right now.
curl -s "https://api.trendsagi.com/api/trends?category=Technology&sort_by=velocity&sort_dir=desc&limit=25" \
-H "X-API-Key: $TRENDSAGI_API_KEY"
For AI context on a single trend, call GET /api/trends/{id}/ai-insights; for a time series, GET /api/trends/{id}/analytics?period=24h. Omit the category parameter to pull across categories, and use period plus limit to control how far back the window reaches.
Step 2: Append rows with the Sheets API
The cleanest write is values.append against the Trends!A:H range. Append finds the table's end and writes below it, so you never have to compute a row number.
import os
from datetime import datetime, timezone
import requests
SHEETS_TOKEN = os.environ["GOOGLE_ACCESS_TOKEN"]
SPREADSHEET_ID = os.environ["SHEETS_SPREADSHEET_ID"]
RANGE = "Trends!A:H"
trends = requests.get(
"https://api.trendsagi.com/api/trends",
headers={"X-API-Key": os.environ["TRENDSAGI_API_KEY"]},
params={"sort_by": "velocity", "sort_dir": "desc", "limit": 25},
timeout=30,
).json()["trends"]
stamp = datetime.now(timezone.utc).isoformat(timespec="seconds")
rows = [
[stamp, t["id"], t["name"], t["category"],
t.get("velocity"), t.get("growth"), t.get("volume"), ""]
for t in trends
]
requests.post(
f"https://sheets.googleapis.com/v4/spreadsheets/{SPREADSHEET_ID}/values/{RANGE}:append",
headers={"Authorization": f"Bearer {SHEETS_TOKEN}"},
params={"valueInputOption": "USER_ENTERED", "insertDataOption": "INSERT_ROWS"},
json={"values": rows},
timeout=30,
).raise_for_status()
If you want a snapshot that replaces the previous one instead of growing, use values.update on the same range. Append plus a dedupe formula (below) is usually the better fit for a trend log.
Step 3: The same pipeline with the Python SDK
The SDK removes the raw HTTP layer for the trend side.
import os
from trendsagi import TrendsAGIClient
client = TrendsAGIClient(api_key=os.environ["TRENDSAGI_API_KEY"])
trends = client.get_trends(category="Technology", sort_by="velocity", limit=5)
for trend in trends["trends"]:
insights = client.get_ai_insights(trend["id"])
print(trend["name"], trend.get("velocity"), insights.get("summary"))
analytics = client.get_trend_analytics(trends["trends"][0]["id"], period="7d")
print(analytics)
Write the returned summary into column H so each row carries a one-line explanation next to the numbers.
Step 4: Prevent duplicate rows
Two layers are worth having. First, make the run idempotent: build a key of Trend ID + date and skip rows already in the sheet. Second, add a helper column for a spreadsheet-side check:
=COUNTIFS($B:$B, B2, INT($A:$A), INT(A2)) > 1
Filter on TRUE and delete duplicates, or wrap the append so it only fires when the key is absent. If you prefer to write fewer rows, run once per day and let the trends endpoint's period parameter define the window rather than appending on every schedule tick.
Step 5: Schedule the refresh
Any scheduler works as long as it can run Python with the two environment variables set. A cron expression like 0 */4 * * * gives six refreshes a day. Log the HTTP status of both calls and alert on non-2xx; silent blanks are the common failure, so also record the row count appended and raise if it is zero.
For alerting without a Sheet in the loop, TrendsAGI supports signed outbound webhooks (POST /api/integrations/webhooks with trigger_type, delivery_mode, keywords and a cooldown) plus Slack notifications. New webhook subscriptions start paused: send POST /api/integrations/webhooks/{id}/test, then PATCH /api/integrations/webhooks/{id} with {"is_active": true}. Each delivery carries an X-Webhook-Signature header — the HMAC-SHA256 of the exact raw request body keyed with your signing secret — so verify it against the unmodified bytes with a constant-time comparison. The body's field list is not documented here; send a test delivery and map fields from what actually arrives.
Which route should you use?
| Route | Setup effort | Freshness | Main failure mode |
|---|---|---|---|
| Google Trends RSS into Sheets | Low | Undocumented cadence | Blank or stale rows with no error |
| Scraper actors | Medium | Per-run | Rate limits, changing markup |
| Commercial connector (e.g. Supermetrics) | Low | Auto-refresh | Subscription cost; 14-day trial then paid |
| TrendsAGI API + Sheets API | Medium (one script) | On your schedule | Your scheduler or token expiry |
Supermetrics documents a Google Sheets connector that pulls Google Trends search interest, regional breakdowns and related queries into auto-refreshing spreadsheets with a 14-day free trial and no card required — pricing after the trial is not stated in the source reviewed. TrendsAGI publishes plans at its subscription page; do not budget from secondhand figures.
Practical use cases
- Editorial calendar: one tab of raw appended rows, one pivot tab by category and day. Content leads scan the pivot, not the log.
- Slack digest: a scheduled job reads the last 24 rows from the Sheet, posts the top five by velocity, and links back to the spreadsheet as the system of record.
- Market research: filter by category over a
period=7dwindow and export the range for a deck; keep the fetch timestamp column so readers know what “now” meant. - Agent access: if someone asks “what's moving in Technology today,” a read-only agent can answer via
list_trendsorfind_capabilityinstead of another brittle scrape.
Troubleshooting
- 401 from TrendsAGI: the key is missing or not exported. Confirm
echo $TRENDSAGI_API_KEYprints a value in the same shell as the script. - 403 from Sheets: the spreadsheet was never shared with the service account email, or the Sheets API is not enabled in the project.
- 400 “Unable to parse range”: the sheet name has a space and is unquoted. Use
'Trends Log'!A:H. - Rows land in the wrong columns: every row must have the same length as the header. Pad missing values with empty strings.
- It stopped writing: check the scheduler log for the appended row count. A zero count with a 200 response usually means the trend query returned nothing — widen
periodor drop the category filter. - 429 responses: back off and run less often. TrendsAGI's rate limits are not published in the sources used here; check your account's API usage endpoint (
GET /api/user/api-usage) instead of guessing.
Frequently asked questions
What is the most reliable data source for trending topics — the Google Trends real-time/RSS feed, a scraper, or a commercial connector?
Feeds and scrapers are cheapest but undocumented on freshness and prone to silent blanks; a commercial connector is stable but paid. A documented trend API with explicit error responses is the most debuggable of the four.
How do I authenticate and call the Google Sheets API to append new trend rows from a script or workflow?
Create a service account, share the spreadsheet with it as an editor, and call spreadsheets/{spreadsheetId}/values/Trends!A:H:append with a Bearer token and valueInputOption=USER_ENTERED.
How do I stop duplicate rows when a run happens more than once a day?
Key each row on trend ID plus calendar date and skip rows already present, then verify with a COUNTIFS helper column across the ID and the integer part of the timestamp.
Can I schedule refreshes automatically, and what breaks when a run fails or a feed returns blanks?
Yes — any cron-style scheduler can run the script. The usual breakage is a 200 response with zero rows, so log the appended count and alert when it drops to zero.
What does each option cost — templates, scraper actors, or subscription connectors — and what are the usage limits?
Templates are free but maintenance-heavy, scrapers bill per run or per 1,000 searches, and connectors use subscriptions; Supermetrics documents a 14-day free trial but not post-trial pricing. TrendsAGI's plans and rate limits are published on its own pages rather than estimated here.
How do I structure the sheet (geo, term, approx traffic, pubDate, news source) so it stays usable for editorial planning?
Keep one raw log tab with a fixed column order and a fetch timestamp on every row, then build pivot tabs for category, day and source. Freeze row 1 and protect the header range so sorting never destroys it.
How we researched this
Prepared by TrendsAGI Research. Facts checked on 21 October 2026 against the sources listed below.
We read the official Google Sheets documentation listed below. The TrendsAGI steps and code use its documented REST API and Python SDK; confirm the Google Sheets side against its current documentation, since third-party products change.
| Claim | Applies to | Source |
|---|---|---|
| The Google Sheets API is a RESTful interface that lets you read and modify spreadsheet data, including creating spreadsheets, reading and writing cell values, updating formatting and managing sheets. | All plans | developers.google.com |
| A spreadsheet is identified by a unique spreadsheetId that can be derived from the spreadsheet URL and does not change when the spreadsheet is renamed. | All plans | developers.google.com |
| Each sheet within a spreadsheet has a unique numeric sheetId and a title, and neither changes when the sheet is renamed. | All plans | developers.google.com |
| A1 notation addresses cells and ranges, e.g. Sheet1!A1:B2 for the first two rows and columns of Sheet1 or Sheet1!A:A for an entire first column. | All plans | developers.google.com |
| Sheet names containing spaces or special characters must be wrapped in single quotes when referenced, e.g. 'My Custom Sheet'!A:A. | All plans | developers.google.com |
| Sheets supports named ranges and protected ranges, represented by the FilterView and ProtectedRange resources respectively. | All plans | developers.google.com |
| Supermetrics offers a Google Sheets connector that pulls Google Trends search interest scores, regional breakdowns and related queries into auto-refreshing spreadsheets, with a free 14-day trial and no credit card required. | Supermetrics for Google Sheets | supermetrics.com |
We re-research and rewrite this page at least every four months; the updated date only changes when the facts are re-checked.
Sources
- Google Sheets API 概览 (Google for Developers) — developers.google.com
- การฝึกอบรมและความช่วยเหลือของ Google ชีต (Google Help) — support.google.com
- Google Sheets: Online spreadsheet editor (Google (Google Workspace)) — workspace.google.com
- Connect Google Trends to Google Sheets — Search Trend Data in Sheets (Supermetrics) — supermetrics.com