You can track TikTok hashtag growth by calling the Scavio TikTok hashtag endpoint daily, storing video_count and view_count in SQLite, and calculating day-over-day growth rates to surface trending tags.
Prerequisites
- Python 3.9+
- Scavio API key with TikTok access
- SQLite (stdlib)
Walkthrough
Step 1: Fetch hashtag stats from the TikTok API
The TikTok hashtag endpoint returns current video count and view count for a hashtag.
import requests
API_KEY = "your-scavio-api-key"
def get_hashtag_stats(hashtag: str) -> dict:
# Remove # if present
tag = hashtag.lstrip("#")
r = requests.post(
f"https://api.scavio.dev/api/v1/tiktok/hashtag",
json={"hashtag": tag},
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=15
)
r.raise_for_status()
return r.json()
stats = get_hashtag_stats("aitools")
print(stats)Step 2: Store daily snapshots in SQLite
Save video_count and view_count for each hashtag each day.
import sqlite3
from datetime import date
def init_db(path="hashtag_tracker.db"):
conn = sqlite3.connect(path)
conn.execute("""
CREATE TABLE IF NOT EXISTS snapshots (
date TEXT,
hashtag TEXT,
video_count INTEGER,
view_count INTEGER,
PRIMARY KEY (date, hashtag)
)
""")
conn.commit()
return conn
def save_snapshot(conn, hashtag: str, stats: dict):
conn.execute(
"INSERT OR REPLACE INTO snapshots VALUES (?, ?, ?, ?)",
(
str(date.today()),
hashtag,
stats.get("video_count", 0),
stats.get("view_count", 0)
)
)
conn.commit()Step 3: Calculate day-over-day growth
Compare today's counts with yesterday's to find fastest-growing hashtags.
def get_growth(conn, hashtag: str) -> dict:
rows = conn.execute(
"SELECT date, video_count, view_count FROM snapshots WHERE hashtag=? ORDER BY date DESC LIMIT 2",
(hashtag,)
).fetchall()
if len(rows) < 2:
return {"hashtag": hashtag, "growth_pct": None}
today_vids = rows[0][1]
yesterday_vids = rows[1][1]
if yesterday_vids == 0:
return {"hashtag": hashtag, "growth_pct": None}
growth = (today_vids - yesterday_vids) / yesterday_vids * 100
return {
"hashtag": hashtag,
"today_videos": today_vids,
"yesterday_videos": yesterday_vids,
"growth_pct": round(growth, 2)
}Step 4: Run the daily tracking cron
Save this as track_hashtags.py and schedule with cron: 0 9 * * * python /path/to/track_hashtags.py
HASHTAGS = ["aitools", "llm", "chatgpt", "claude", "openai", "cursor", "vibe coding"]
conn = init_db()
results = []
for tag in HASHTAGS:
try:
stats = get_hashtag_stats(tag)
save_snapshot(conn, tag, stats)
growth = get_growth(conn, tag)
results.append(growth)
except Exception as e:
print(f"Error tracking #{tag}: {e}")
# Print trending hashtags (growth > 5%)
results.sort(key=lambda x: x.get("growth_pct") or 0, reverse=True)
print("\nTrending hashtags today:")
for r in results:
if r.get("growth_pct") and r["growth_pct"] > 5:
print(f" #{r['hashtag']}: +{r['growth_pct']}% new videos")Python Example
import requests
import sqlite3
from datetime import date
API_KEY = "your-scavio-api-key"
HASHTAGS = ["aitools", "llm", "chatgpt", "claude", "openai", "cursor"]
def get_hashtag_stats(tag: str) -> dict:
r = requests.post(
"https://api.scavio.dev/api/v1/tiktok/hashtag",
json={"hashtag": tag.lstrip("#")},
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=15
)
r.raise_for_status()
return r.json()
def init_db(path="hashtag_tracker.db"):
conn = sqlite3.connect(path)
conn.execute("CREATE TABLE IF NOT EXISTS snapshots (date TEXT, hashtag TEXT, video_count INTEGER, view_count INTEGER, PRIMARY KEY (date, hashtag))")
conn.commit()
return conn
def save(conn, tag, stats):
conn.execute("INSERT OR REPLACE INTO snapshots VALUES (?,?,?,?)",
(str(date.today()), tag, stats.get("video_count",0), stats.get("view_count",0)))
conn.commit()
def growth(conn, tag):
rows = conn.execute("SELECT video_count FROM snapshots WHERE hashtag=? ORDER BY date DESC LIMIT 2", (tag,)).fetchall()
if len(rows) < 2 or rows[1][0] == 0:
return None
return round((rows[0][0] - rows[1][0]) / rows[1][0] * 100, 2)
if __name__ == "__main__":
conn = init_db()
print(f"TikTok Hashtag Report — {date.today()}")
print("-" * 50)
for tag in HASHTAGS:
try:
stats = get_hashtag_stats(tag)
save(conn, tag, stats)
g = growth(conn, tag)
g_str = f"+{g}%" if g and g > 0 else (f"{g}%" if g else "no prior data")
print(f"#{tag:<20} {stats.get('video_count',0):>12,} videos | growth: {g_str}")
except Exception as e:
print(f"#{tag}: error - {e}")JavaScript Example
const API_KEY = 'your-scavio-api-key';
const HASHTAGS = ['aitools', 'llm', 'chatgpt', 'claude', 'cursor'];
async function getHashtagStats(tag) {
const res = await fetch('https://api.scavio.dev/api/v1/tiktok/hashtag', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}` },
body: JSON.stringify({ hashtag: tag.replace(/^#/, '') })
});
if (!res.ok) throw new Error(`Failed: ${res.status}`);
return res.json();
}
for (const tag of HASHTAGS) {
const stats = await getHashtagStats(tag);
console.log(`#${tag}: ${stats.video_count?.toLocaleString()} videos, ${stats.view_count?.toLocaleString()} views`);
}Expected Output
TikTok Hashtag Report - 2026-05-22
--------------------------------------------------
#aitools 1,247,832 videos | growth: +3.2%
#llm 892,441 videos | growth: +8.7%
#chatgpt 4,102,991 videos | growth: +1.1%
#claude 341,209 videos | growth: +12.4%
#openai 2,890,112 videos | growth: +0.8%
#cursor 198,441 videos | growth: +15.2%