User-generated content from TikTok hashtags is the richest source of authentic brand mentions, product reviews, and creative assets for marketing. This collector scans hashtag feeds, filters videos by engagement thresholds, and builds a structured UGC library with metadata. Each hashtag scan costs $0.005 through the Scavio TikTok API.
Prerequisites
- Python 3.8+
- requests library
- A Scavio API key from scavio.dev
- Target hashtags to scan for UGC
Walkthrough
Step 1: Scan hashtag feeds for videos
Pull recent videos from target hashtags.
import os, requests, json
from datetime import datetime
API_KEY = os.environ['SCAVIO_API_KEY']
TH = {'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'}
def scan_hashtag(tag):
data = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag/videos',
headers=TH, json={'name': tag}).json()
videos = data.get('videos', data.get('data', {}).get('videos', []))
return [{'id': v.get('id', ''), 'desc': v.get('desc', '')[:100],
'author': v.get('author', {}).get('uniqueId', 'unknown'),
'plays': v.get('stats', {}).get('playCount', 0),
'likes': v.get('stats', {}).get('diggCount', 0),
'comments': v.get('stats', {}).get('commentCount', 0),
'shares': v.get('stats', {}).get('shareCount', 0),
'created': v.get('createTime', 0)} for v in videos]
videos = scan_hashtag('amazonfinds')
print(f'#amazonfinds: {len(videos)} videos found')
for v in videos[:3]:
print(f' @{v["author"]}: {v["desc"][:50]}... ({v["plays"]:,} plays)')Step 2: Filter by engagement thresholds
Keep only high-performing UGC that meets minimum engagement criteria.
def filter_ugc(videos, min_plays=10000, min_likes=500, min_engagement_rate=3.0):
qualified = []
for v in videos:
plays = v.get('plays', 0)
if plays < min_plays:
continue
engagement = v['likes'] + v['comments'] + v['shares']
er = (engagement / plays * 100) if plays else 0
if v['likes'] >= min_likes and er >= min_engagement_rate:
v['engagement_rate'] = round(er, 2)
qualified.append(v)
qualified.sort(key=lambda x: x['engagement_rate'], reverse=True)
print(f'Filtered: {len(qualified)}/{len(videos)} videos meet criteria')
print(f' Min plays: {min_plays:,}, Min likes: {min_likes}, Min ER: {min_engagement_rate}%')
return qualified
filtered = filter_ugc(videos)
for v in filtered[:5]:
print(f' @{v["author"]:20} | {v["plays"]:>10,} plays | {v["engagement_rate"]}% ER | {v["desc"][:40]}')Step 3: Scan multiple hashtags and deduplicate
Collect UGC across related hashtags and remove duplicate videos.
def collect_ugc(hashtags, min_plays=10000, min_likes=500):
all_videos = []
seen_ids = set()
for tag in hashtags:
videos = scan_hashtag(tag)
for v in videos:
if v['id'] not in seen_ids:
v['hashtag'] = tag
all_videos.append(v)
seen_ids.add(v['id'])
print(f' #{tag}: {len(videos)} videos ({len(seen_ids)} unique total)')
filtered = filter_ugc(all_videos, min_plays=min_plays, min_likes=min_likes)
cost = len(hashtags) * 0.005
print(f'\nTotal: {len(filtered)} qualified UGC from {len(hashtags)} hashtags')
print(f'Cost: ${cost:.3f}')
return filtered
hashtags = ['amazonfinds', 'tiktokmademebuyit', 'musthave', 'productreview']
ugc_library = collect_ugc(hashtags)Step 4: Build and export the UGC library
Save the curated UGC library with metadata for marketing use.
def export_ugc_library(ugc, filename='ugc_library.json'):
library = {
'collected_at': datetime.now().isoformat(),
'total_videos': len(ugc),
'videos': []
}
for v in ugc:
library['videos'].append({
'video_id': v['id'],
'author': v['author'],
'description': v['desc'],
'hashtag_source': v.get('hashtag', ''),
'metrics': {
'plays': v['plays'], 'likes': v['likes'],
'comments': v['comments'], 'shares': v['shares'],
'engagement_rate': v.get('engagement_rate', 0)
},
'tiktok_url': f'https://www.tiktok.com/@{v["author"]}/video/{v["id"]}'
})
with open(filename, 'w') as f:
json.dump(library, f, indent=2)
# Stats
avg_er = sum(v.get('engagement_rate', 0) for v in ugc) / len(ugc) if ugc else 0
avg_plays = sum(v['plays'] for v in ugc) / len(ugc) if ugc else 0
print(f'\nUGC Library saved to {filename}')
print(f' Videos: {len(ugc)}')
print(f' Avg engagement rate: {avg_er:.2f}%')
print(f' Avg plays: {avg_plays:,.0f}')
print(f' Top creator: @{ugc[0]["author"]}' if ugc else '')
export_ugc_library(ugc_library)Python Example
import os, requests
TH = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}', 'Content-Type': 'application/json'}
def collect(hashtag, min_plays=10000):
data = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag/videos',
headers=TH, json={'name': hashtag}).json()
videos = data.get('videos', data.get('data', {}).get('videos', []))
filtered = [v for v in videos if v.get('stats', {}).get('playCount', 0) >= min_plays]
print(f'#{hashtag}: {len(filtered)}/{len(videos)} videos with {min_plays:,}+ plays. Cost: $0.005')
for v in filtered[:3]:
print(f' @{v.get("author", {}).get("uniqueId", "?")}: {v.get("desc", "")[:40]}')
collect('amazonfinds')JavaScript Example
const TH = { 'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json' };
async function collect(hashtag, minPlays = 10000) {
const data = await fetch('https://api.scavio.dev/api/v1/tiktok/hashtag/videos', {
method: 'POST', headers: TH, body: JSON.stringify({ name: hashtag })
}).then(r => r.json());
const videos = (data.videos || data.data?.videos || []);
const filtered = videos.filter(v => (v.stats?.playCount || 0) >= minPlays);
console.log(`#${hashtag}: ${filtered.length}/${videos.length} with ${minPlays.toLocaleString()}+ plays`);
filtered.slice(0, 3).forEach(v =>
console.log(` @${v.author?.uniqueId || '?'}: ${(v.desc || '').slice(0, 40)}`));
}
await collect('amazonfinds');Expected Output
#amazonfinds: 20 videos found
@sarahfinds: This Stanley tumbler color is everything... (2,400,000 plays)
@dealsqueen: Under $15 Amazon finds you NEED... (1,800,000 plays)
#amazonfinds: 20 videos (20 unique total)
#tiktokmademebuyit: 18 videos (35 unique total)
#musthave: 15 videos (44 unique total)
#productreview: 12 videos (50 unique total)
Filtered: 18/50 videos meet criteria
UGC Library saved to ugc_library.json
Videos: 18
Avg engagement rate: 7.34%
Avg plays: 890,000