Tutorial

How to Track TikTok Hashtag Trends via API

Monitor TikTok hashtag growth over time by polling hashtag info daily. Python example using Scavio API for trend detection.

Track TikTok hashtag trends by polling the hashtag info endpoint daily at $0.005/check. Monitor view count growth, video count changes, and detect trending hashtags before they peak.

Prerequisites

  • Scavio API key
  • Python 3.8+
  • A list of hashtags to monitor
  • Simple storage (CSV or SQLite)

Walkthrough

Step 1: Check hashtag stats

Pull current view and video counts for your hashtag list.

Python
import requests, os, csv
from datetime import date

HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
           'Content-Type': 'application/json'}

hashtags = ['smallbusiness', 'sidehustle', 'techtok', 'booktok']
today = date.today().isoformat()

for tag in hashtags:
    data = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag',
        headers=HEADERS, json={'hashtag': tag}).json()['data']
    views = data['stats']['view_count']
    videos = data['stats']['video_count']
    print(f'#{tag}: {views:,} views, {videos:,} videos')

Step 2: Store daily snapshots

Append to a CSV for trend analysis over time.

Python
with open('hashtag_trends.csv', 'a', newline='') as f:
    w = csv.writer(f)
    for tag in hashtags:
        data = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag',
            headers=HEADERS, json={'hashtag': tag}).json()['data']
        w.writerow([today, tag,
            data['stats']['view_count'],
            data['stats']['video_count']])

Python Example

Python
import requests, os, csv, json
from datetime import date

HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
           'Content-Type': 'application/json'}

def track_hashtags(tags, history_file='hashtag_history.json'):
    today = date.today().isoformat()
    try:
        with open(history_file) as f:
            history = json.load(f)
    except FileNotFoundError:
        history = {}
    results = []
    for tag in tags:
        data = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag',
            headers=HEADERS, json={'hashtag': tag}).json()['data']
        views = data['stats']['view_count']
        prev = history.get(tag, {}).get('views', views)
        growth = ((views - prev) / prev * 100) if prev else 0
        results.append({'tag': tag, 'views': views, 'growth_pct': round(growth, 1)})
        history[tag] = {'views': views, 'date': today}
    with open(history_file, 'w') as f:
        json.dump(history, f)
    return sorted(results, key=lambda x: x['growth_pct'], reverse=True)

trends = track_hashtags(['smallbusiness', 'sidehustle', 'techtok'])
for t in trends:
    print(f"#{t['tag']}: {t['views']:,} views ({t['growth_pct']:+.1f}%)")

JavaScript Example

JavaScript
const H = {'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json'};
const fs = require('fs');
async function trackHashtags(tags) {
  let history = {};
  try { history = JSON.parse(fs.readFileSync('hashtag_history.json')); } catch {}
  for (const tag of tags) {
    const r = await fetch('https://api.scavio.dev/api/v1/tiktok/hashtag', {
      method: 'POST', headers: H, body: JSON.stringify({hashtag: tag})
    }).then(r => r.json());
    const views = r.data.stats.view_count;
    const prev = history[tag]?.views || views;
    const growth = prev ? ((views - prev) / prev * 100).toFixed(1) : '0.0';
    console.log(`#${tag}: ${views.toLocaleString()} views (${growth}%)`);
    history[tag] = {views, date: new Date().toISOString().split('T')[0]};
  }
  fs.writeFileSync('hashtag_history.json', JSON.stringify(history));
}
trackHashtags(['smallbusiness', 'sidehustle', 'techtok']);

Expected Output

JSON
Daily hashtag metrics with growth percentages, enabling trend detection over time. Run as a daily cron for continuous monitoring.

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Scavio API key. Python 3.8+. A list of hashtags to monitor. Simple storage (CSV or SQLite). A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Monitor TikTok hashtag growth over time by polling hashtag info daily. Python example using Scavio API for trend detection.