Ranking January fitness keywords takes three series calls and one growth call per term. The Python script in this tutorial pulls weekly Google Search series for gym membership, workout and weight loss, extracts each year's January peak and monthly average across 2022 to 2026, and ranks the terms by within-term peak growth. Gym membership leads the ranking, its January peak climbing in each successive year, 19 in 2022 up to 54 in 2026. Weight loss ranks second, from 35 to 51, with dips to 41 in 2024 and 38 in 2025. Workout ranks third, from 69 to 76, on a much flatter path. Latest readings dated November 21, 2026: gym membership 25, workout 46, weight loss 25. The three terms are worked examples, and the ranking carries no monthly volume figure; the Keyword Planner request failed during this run.
The script pulls one series per term
Each get_time_series call returns weekly points with date and value fields. The REST envelope carries body as a JSON string, so call_api parses that string with json.loads before any field access.
import json
import os
import statistics
import requests
API_URL = "https://api.trendsmcp.ai/api"
SOURCE = "Google Search"
TERMS = ["gym membership", "workout", "weight loss"]
YEARS = [2022, 2023, 2024, 2025, 2026]
def call_api(payload):
key = os.environ["TRENDS_API_KEY"]
response = requests.post(
API_URL,
json=payload,
headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"},
timeout=60,
)
response.raise_for_status()
envelope = response.json()
body = envelope["body"]
parsed = json.loads(body) if isinstance(body, str) else body
if envelope.get("statusCode") != 200:
message = parsed.get("message", "Trends API request failed") if isinstance(parsed, dict) else "Trends API request failed"
raise RuntimeError(message)
return parsed
def fetch_series(term):
points = call_api({"mode": "get_time_series", "keyword": term, "source": SOURCE})
points.sort(key=lambda point: str(point["date"]))
return [(str(point["date"])[:10], float(point["value"])) for point in points]
def january_stats(points):
stats = {}
for year in YEARS:
january = [(date, value) for date, value in points if date.startswith(f"{year}-01")]
if not january:
continue
peak_date, peak_value = max(january, key=lambda item: item[1])
stats[year] = {
"peak": peak_value,
"peak_date": peak_date,
"january_average": round(statistics.mean(value for _, value in january), 1),
}
return stats
ranked = []
for term in TERMS:
stats = january_stats(fetch_series(term))
base_peak = stats.get(2022, {}).get("peak", 0)
recent_peak = stats.get(2026, {}).get("peak", 0)
if not base_peak or not recent_peak:
print(term, "skipped: missing January peak")
continue
ranked.append((term, round(recent_peak / base_peak, 2), stats))
for term, ratio, stats in sorted(ranked, key=lambda item: item[1], reverse=True):
print(term, "peak growth 2022 to 2026:", ratio)
The Google Trends API setup guide covers key setup for a first run.
Growth calls add the current position
Series statistics describe the season; growth calls describe the current week. One get_growth call per term returns every requested window. Append this block to the same script:
def fetch_growth(term):
data = call_api(
{
"mode": "get_growth",
"keyword": term,
"source": SOURCE,
"percent_growth": ["1M", "3M", "12M"],
}
)
return {result["period"]: result for result in data["results"]}
for term in TERMS:
growth = fetch_growth(term)
for period in ["1M", "3M", "12M"]:
result = growth[period]
if not result["baseline_value"]:
print(term, period, "skipped: zero baseline")
continue
print(
term, period,
"baseline", result["baseline_value"], "on", str(result["baseline_date"])[:10],
"recent", result["recent_value"], "on", str(result["recent_date"])[:10],
"growth", result["growth"],
)
Each result carries recent_value, baseline_value, growth, recent_date and baseline_date. Recording the dates beside the percentages keeps a stale pull visible: a growth figure whose recent date sits weeks behind the run date describes an old week, and the ranking should say so. In the November 28 run, every recent date read November 21, 2026, one week behind the pull date, which matches the weekly series cadence.
The growth output also guards against a zero baseline. A percentage computed from a baseline value of 0 carries no information, so production code should skip the percentage and report the dated values instead. None of the three fitness terms hit that case in this run: baselines across the nine windows run from 22 to 66.
January peaks separate the three terms
The three terms differ in calendar-January peak growth. The ratio measures January growth only: the gym membership series reaches 100 on February 21, 2026, above its January peak of 54, so a full-season ranking would need a wider window:
| Term | Jan peak 2022 | Jan peak 2026 | Peak growth | Peak path | Jan average 2026 |
|---|---|---|---|---|---|
| Gym membership | 19 (Jan 8) | 54 (Jan 31) | 2.84x | 19, 24, 27, 30, 54 | 49.8 |
| Weight loss | 35 (Jan 8) | 51 (Jan 10) | 1.46x | 35, 42, 41, 38, 51 | 46.2 |
| Workout | 69 (Jan 8) | 76 (Jan 10) | 1.10x | 69, 70, 65, 65, 76 | 70.6 |
Only gym membership raised its peak in all five years, with the January average moving from 16.4 in 2022 to 49.8 in 2026 alongside it. Weight loss dipped to 38 in 2025 before reaching 51 in 2026. Workout stayed high and flat through January, peaks spanning 65 to 76 and monthly averages spanning 61.5 to 70.6.
Peak heights across terms stay out of the ranking. Each series carries its own 0 to 100 scale, so a workout peak of 76 is not a larger search count than a gym membership peak of 54. The ranking compares each term against its own 2022 peak.
Gym membership leads the ranked output
The sorted output prints one line per term, strongest peak growth first:
gym membership peak growth 2022 to 2026: 2.84
weight loss peak growth 2022 to 2026: 1.46
workout peak growth 2022 to 2026: 1.1
Each ratio divides the 2026 January peak by the 2022 January peak for the same term. Gym membership at 2.84x means the 2026 peak of 54 stands at 2.84 times the 2022 peak of 19, on the gym membership scale. The ratio says nothing about absolute search counts. The ranked list keeps the full January statistics in memory beside each ratio, so a reader can extend the printout to check the dates behind the ranking. January averages use the four or five weekly points dated in each January.
A term with no 2022 January peak prints a skipped line instead of a ratio. That guard matters for newer terms whose series start after 2022: dividing by a missing or zero baseline would produce a ranking with no evidence behind it. The January statistics dictionary also records the peak date per year, so a late peak such as January 31 stays available in the statistics rather than hiding inside a monthly maximum.
Current readings sit below the January season
Growth calls pulled November 28, 2026, with recent date November 21, 2026, put all three terms below their January 2026 averages: gym membership 49.8, workout 70.6, weight loss 46.2. Gym membership reads 25 on November 21, up 13.64% in 1 month from 22, down 47.92% in 3 months from 48. Workout reads 46, down 2.13% in 1 month and 30.3% in 3 months. Weight loss reads 25, down 3.85% in 1 month and 52.83% in 3 months.
Endpoint percentages rest on single weeks, which is why the script files them as context. The January statistics carry the ranking, because five Januaries of dated peaks say more about the coming season than one November week. The seasonality detector tutorial extends the same series work to general seasonal terms.
A December re-pull updates the ranking
A re-pull in mid-December 2026 updates the growth context. December readings show whether each term builds toward its January range. A January 2027 ranking needs the year list extended first, since the script compares 2022 against 2026. The 12M window adds the year-ago context at baseline: gym membership -19.35% from 31, workout -23.33% from 60 and weight loss -41.86% from 43. The trend spike alerts tutorial covers alert rules on the same calls.
Two limits apply. Monthly volume is absent: the Keyword Planner request failed during this run, leaving index growth as the ranking basis. Gym membership peaked on January 31 in 2026, weeks after the January 8-or-earlier peaks of 2022 to 2025, so a check ending in the first week would miss a late peak. The script reads the full month for that reason.