ScavioScavio
ProductPricingDocs
Sign InGet Started
Blog
tiktoktrend-detectionapihashtaganalytics

TikTok Hashtag Trend Detection with a Daily API Pipeline

Monitor hashtag video counts over time to detect rising trends. TikTok hashtag endpoint plus a daily cron gives early trend signals before topics peak.

May 22, 2026
6 min read

TikTok Hashtag Trend Detection with a Daily API Pipeline

Monitor hashtag video counts over time to detect rising trends. TikTok hashtag endpoint plus a daily cron gives early trend signals before topics peak on mainstream platforms. The core signal: a hashtag whose video count grows 20%+ week-over-week is accelerating faster than typical organic growth.

Why Hashtag Video Count Works as a Trend Signal

TikTok video counts for hashtags grow as creators post to that tag. A hashtag with 50,000 videos that adds 5,000 videos in a week (10% growth) is growing at a normal pace. The same hashtag adding 15,000 videos in a week (30% growth) indicates an accelerating trend — more creators are jumping on it.

This signal works best for:

  • Niche topics before they get picked up by larger media (2-4 week lead time on trend articles)
  • Product categories ("#WaterPistol2026" growth predicts seasonal demand)
  • Audio trends (music-related hashtags that predict chart movement)
  • Brand monitoring (sudden growth in brand hashtags signals viral events)

The Pipeline

Python
import requests
import sqlite3
from datetime import date

DB_PATH = "/opt/trends/hashtags.db"
TARGET_HASHTAGS = [
    "handmadejewelry", "smallbusiness2026", "sustainablefashion",
    "aitools", "solopreneur", "remotework2026"
]

def fetch_hashtag_stats(tag: str) -> dict:
    resp = requests.post(
        "https://api.scavio.dev/api/v1/tiktok/hashtag_info",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={"name": tag}
    )
    data = resp.json()
    return {
        "tag": tag,
        "video_count": data.get("video_count", 0),
        "view_count": data.get("view_count", 0),
        "date": date.today().isoformat()
    }

def store_stats(stats: dict, conn: sqlite3.Connection):
    conn.execute("""
        INSERT INTO hashtag_history (tag, video_count, view_count, recorded_date)
        VALUES (?, ?, ?, ?)
    """, (stats["tag"], stats["video_count"], stats["view_count"], stats["date"]))
    conn.commit()

def calculate_growth(tag: str, conn: sqlite3.Connection, days: int = 7) -> float:
    rows = conn.execute("""
        SELECT video_count FROM hashtag_history
        WHERE tag = ?
        ORDER BY recorded_date DESC
        LIMIT ?
    """, (tag, days + 1)).fetchall()

    if len(rows) < 2:
        return 0.0

    current = rows[0][0]
    baseline = rows[-1][0]
    if baseline == 0:
        return 0.0

    return (current - baseline) / baseline

def run_daily():
    conn = sqlite3.connect(DB_PATH)
    alerts = []

    for tag in TARGET_HASHTAGS:
        stats = fetch_hashtag_stats(tag)
        store_stats(stats, conn)

        growth_7d = calculate_growth(tag, conn, days=7)
        if growth_7d > 0.20:  # 20%+ week-over-week
            alerts.append({
                "tag": tag,
                "growth_7d_pct": round(growth_7d * 100, 1),
                "current_videos": stats["video_count"]
            })

    conn.close()
    return alerts

Schedule with cron: 0 6 * * * python /opt/trends/run_daily.py

Cost: 1 credit per hashtag per day. For 50 hashtags monitored daily: 50 credits/day = $0.25/day = $7.50/month.

Database Setup

CREATE TABLE hashtag_history (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    tag TEXT NOT NULL,
    video_count INTEGER,
    view_count INTEGER,
    recorded_date DATE,
    UNIQUE(tag, recorded_date)
);

CREATE INDEX idx_tag_date ON hashtag_history(tag, recorded_date DESC);

The UNIQUE constraint on (tag, recorded_date) prevents duplicate daily records if the cron runs twice.

Layering in Video Content

Once you identify a trending hashtag, pull recent videos to understand what content is driving growth:

Python
def analyze_trending_hashtag(tag: str) -> list[dict]:
    resp = requests.post(
        "https://api.scavio.dev/api/v1/tiktok/hashtag_videos",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={"name": tag, "count": 20}
    )
    videos = resp.json().get("videos", [])
    # Sort by view count to see what's performing
    return sorted(videos, key=lambda v: v.get("play_count", 0), reverse=True)

This costs 1 additional credit per trending hashtag analysis. For 5 alerts/week requiring deep analysis: 5 credits = $0.025/week.

Threshold Calibration

The 20% weekly growth threshold is a starting point. Calibrate based on your hashtag set:

  • Small hashtags (under 100k videos): 20% growth is common noise; raise threshold to 50%+
  • Large hashtags (over 5M videos): 5% growth represents massive absolute volume; lower threshold to 5-10%
  • Seasonal hashtags: normalize against historical same-week-prior-year data to avoid false alerts from predictable seasonality

Continue reading

aeod2c

AEO Tracking for D2C Ecommerce Brands in 2026

6 min read
ai-agentscost-optimization

Agent Discovery vs Extraction: Why Cost Split Matters

6 min read
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy