Un système de surveillance de marque économique pour TikTok suit les mentions de votre marque, analyse le sentiment des commentaires et surveille l'activité des concurrents sans abonnements coûteux de social listening. Avec l'API TikTok Scavio à 0,005 $/crédit, vous pouvez rechercher des vidéos mentionnant votre marque, extraire les commentaires pour l'analyse des sentiments et surveiller les hashtags concurrents, le tout dans le cadre d'un forfait à 30 $/mois. Ce tutoriel construit un pipeline de surveillance complet qui s'exécute via une tâche cron quotidienne et génère un rapport de synthèse.
Prérequis
- Python 3.10+ installé
- bibliothèque requests installée
- Une clé API Scavio depuis scavio.dev
- Connaissance de base de la terminologie du contenu TikTok (hashtags, aweme_id)
Parcours
Étape 1: Rechercher des mentions de marque sur TikTok
Utilisez l'endpoint search/videos de TikTok pour trouver les vidéos récentes mentionnant votre nom de marque. Cela capture à la fois les mentions directes dans les descriptions et le contenu connexe.
import requests, os
from datetime import datetime
API_KEY = os.environ['SCAVIO_API_KEY']
HEADERS = {'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'}
def search_brand_mentions(brand: str, pages: int = 3) -> list:
videos = []
cursor = 0
for _ in range(pages):
resp = requests.post('https://api.scavio.dev/api/v1/tiktok/search/videos',
headers=HEADERS,
json={'keyword': brand, 'count': 20, 'cursor': cursor})
data = resp.json()['data']
videos.extend(data.get('videos', []))
if not data.get('has_more'):
break
cursor = data['cursor']
return videos
mentions = search_brand_mentions('yourBrandName')
print(f'Found {len(mentions)} videos mentioning brand')Étape 2: Extraire le sentiment des commentaires par mention
Pour chaque vidéo mentionnant votre marque, extrayez les commentaires et classez le sentiment à l'aide d'un simple appariement de mots-clés. Pour une utilisation en production, remplacez par un classificateur LLM.
POSITIVE_WORDS = {'love', 'amazing', 'great', 'best', 'perfect', 'awesome', 'recommend'}
NEGATIVE_WORDS = {'hate', 'worst', 'terrible', 'scam', 'broken', 'awful', 'waste'}
def get_comments(video_id: str, pages: int = 2) -> list:
comments = []
cursor = 0
for _ in range(pages):
resp = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
headers=HEADERS,
json={'aweme_id': video_id, 'count': 20, 'cursor': cursor})
data = resp.json()['data']
comments.extend(data.get('comments', []))
if not data.get('has_more'):
break
cursor = data.get('cursor', cursor + 20)
return comments
def classify_sentiment(comments: list) -> dict:
counts = {'positive': 0, 'negative': 0, 'neutral': 0}
for c in comments:
words = set(c['text'].lower().split())
if words & POSITIVE_WORDS:
counts['positive'] += 1
elif words & NEGATIVE_WORDS:
counts['negative'] += 1
else:
counts['neutral'] += 1
return countsÉtape 3: Surveiller les hashtags concurrents
Suivez les hashtags de marque des concurrents pour comparer leur présence sur TikTok à la vôtre. Comparez le nombre de vues et le volume de vidéos au fil du temps.
def monitor_hashtag(hashtag: str) -> dict:
resp = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag',
headers=HEADERS, json={'hashtag': hashtag})
data = resp.json()['data']
return {
'hashtag': hashtag,
'views': data['stats']['view_count'],
'videos': data['stats']['video_count']
}
competitors = ['competitorA', 'competitorB', 'yourBrand']
for tag in competitors:
stats = monitor_hashtag(tag)
print(f'#{stats["hashtag"]}: {stats["views"]:,} views, {stats["videos"]:,} videos')Étape 4: Générer un rapport de synthèse quotidien
Combinez les mentions de marque, les sentiments et les données concurrentes dans un rapport JSON quotidien. Planifiez ceci avec cron pour une surveillance automatisée.
import json
from datetime import date
def daily_report(brand: str, competitors: list) -> dict:
mentions = search_brand_mentions(brand, pages=2)
total_sentiment = {'positive': 0, 'negative': 0, 'neutral': 0}
for v in mentions[:10]: # Sample top 10 for budget
comments = get_comments(v['aweme_id'], pages=1)
sentiment = classify_sentiment(comments)
for k in total_sentiment:
total_sentiment[k] += sentiment[k]
comp_stats = [monitor_hashtag(c) for c in competitors]
report = {
'date': date.today().isoformat(),
'brand': brand,
'mentions_found': len(mentions),
'sentiment': total_sentiment,
'competitors': comp_stats
}
with open(f'brand_report_{date.today()}.json', 'w') as f:
json.dump(report, f, indent=2)
return report
report = daily_report('yourBrand', ['competitorA', 'competitorB'])
print(json.dumps(report, indent=2))Exemple Python
import requests, os, json
from datetime import date
API_KEY = os.environ['SCAVIO_API_KEY']
HEADERS = {'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'}
def search_mentions(brand, pages=2):
videos, cursor = [], 0
for _ in range(pages):
data = requests.post('https://api.scavio.dev/api/v1/tiktok/search/videos',
headers=HEADERS, json={'keyword': brand, 'count': 20, 'cursor': cursor}).json()['data']
videos.extend(data.get('videos', []))
if not data.get('has_more'): break
cursor = data['cursor']
return videos
def get_comments(vid_id, pages=1):
comments, cursor = [], 0
for _ in range(pages):
data = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
headers=HEADERS, json={'aweme_id': vid_id, 'count': 20, 'cursor': cursor}).json()['data']
comments.extend(data.get('comments', []))
if not data.get('has_more'): break
cursor = data.get('cursor', cursor + 20)
return comments
def hashtag_stats(tag):
data = requests.post('https://api.scavio.dev/api/v1/tiktok/hashtag',
headers=HEADERS, json={'hashtag': tag}).json()['data']
return {'hashtag': tag, 'views': data['stats']['view_count'], 'videos': data['stats']['video_count']}
mentions = search_mentions('yourBrand')
print(f'{len(mentions)} mentions found')
for v in mentions[:5]:
comments = get_comments(v['aweme_id'])
print(f" {v['desc'][:40]} -> {len(comments)} comments")
for c in ['competitorA', 'competitorB']:
s = hashtag_stats(c)
print(f"#{s['hashtag']}: {s['views']:,} views")Exemple JavaScript
const API_KEY = process.env.SCAVIO_API_KEY;
const H = { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' };
async function searchMentions(brand, pages = 2) {
const videos = [];
let cursor = 0;
for (let i = 0; i < pages; i++) {
const r = await fetch('https://api.scavio.dev/api/v1/tiktok/search/videos', {
method: 'POST', headers: H,
body: JSON.stringify({ keyword: brand, count: 20, cursor })
}).then(r => r.json());
videos.push(...(r.data.videos || []));
if (!r.data.has_more) break;
cursor = r.data.cursor;
}
return videos;
}
async function getComments(videoId) {
const r = await fetch('https://api.scavio.dev/api/v1/tiktok/video/comments', {
method: 'POST', headers: H,
body: JSON.stringify({ aweme_id: videoId, count: 20, cursor: 0 })
}).then(r => r.json());
return r.data.comments || [];
}
async function hashtagStats(tag) {
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());
return { hashtag: tag, views: r.data.stats.view_count };
}
async function main() {
const mentions = await searchMentions('yourBrand');
console.log(`${mentions.length} brand mentions`);
for (const v of mentions.slice(0, 5)) {
const comments = await getComments(v.aweme_id);
console.log(` ${v.desc.slice(0, 40)} -> ${comments.length} comments`);
}
for (const c of ['competitorA', 'competitorB']) {
const s = await hashtagStats(c);
console.log(`#${s.hashtag}: ${s.views.toLocaleString()} views`);
}
}
main().catch(console.error);Sortie attendue
{
"date": "2026-05-12",
"brand": "yourBrand",
"mentions_found": 38,
"sentiment": {
"positive": 42,
"negative": 7,
"neutral": 31
},
"competitors": [
{ "hashtag": "competitorA", "views": 2400000, "videos": 1200 },
{ "hashtag": "competitorB", "views": 890000, "videos": 430 }
]
}