El contenido generado por el usuario a partir de hashtags de TikTok es la fuente más rica de menciones de marca auténticas, reseñas de productos y activos creativos para marketing. Este recopilador escanea feeds de hashtags, filtra videos según umbrales de participación y crea una biblioteca UGC estructurada con metadatos. Cada escaneo de hashtag cuesta $0.005 a través de la API Scavio TikTok.
Requisitos previos
- Python 3.8+
- solicita biblioteca
- Una clave API de Scavio de scavio.dev
- Apunte a hashtags para buscar UGC
Guia paso a paso
Paso 1: Escanear feeds de hashtags en busca de vídeos
Extraiga vídeos recientes de los hashtags de destino.
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)')Paso 2: Filtrar por umbrales de participación
Mantenga solo UGC de alto rendimiento que cumpla con los criterios mínimos de participación.
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]}')Paso 3: Escanea múltiples hashtags y deduplica
Recopile UGC en hashtags relacionados y elimine videos duplicados.
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)Paso 4: Construya y exporte la biblioteca UGC
Guarde la biblioteca UGC seleccionada con metadatos para uso de marketing.
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)Ejemplo en Python
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')Ejemplo en JavaScript
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');Salida esperada
#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