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.
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.
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
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
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
Daily hashtag metrics with growth percentages, enabling trend detection over time. Run as a daily cron for continuous monitoring.