Tutorial

How to Build TikTok Social Listening

Monitor TikTok for brand mentions, video comments, and sentiment signals. Daily pipeline using Scavio TikTok API at $0.005/call.

TikTok social listening catches brand mentions, product discussions, and sentiment shifts that do not appear on any other platform. This pipeline searches TikTok videos for brand keywords, pulls comments from relevant videos, classifies sentiment, and generates a daily digest. Each search and comment pull costs $0.005.

Prerequisites

  • Python 3.8+
  • requests library
  • A Scavio API key from scavio.dev
  • Brand terms and keywords to monitor

Walkthrough

Step 1: Search TikTok videos for brand mentions

Find videos that mention your brand or product category.

Python
import os, requests, json
from datetime import datetime
from collections import Counter

API_KEY = os.environ['SCAVIO_API_KEY']
TH = {'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'}
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

BRAND_TERMS = ['scavio', 'serp api', 'search api']

def search_tiktok(query):
    data = requests.post('https://api.scavio.dev/api/v1/tiktok/search/videos',
        headers=TH, json={'query': query}).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)} for v in videos]

all_videos = []
for term in BRAND_TERMS:
    videos = search_tiktok(term)
    all_videos.extend(videos)
    print(f'  "{term}": {len(videos)} videos found')
print(f'Total: {len(all_videos)} videos. Cost: ${len(BRAND_TERMS) * 0.005:.3f}')

Step 2: Pull comments from relevant videos

Fetch comments from high-engagement videos for sentiment analysis.

Python
def get_comments(video_id):
    data = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
        headers=TH, json={'video_id': video_id}).json()
    comments = data.get('comments', data.get('data', {}).get('comments', []))
    return [{'text': c.get('text', '')[:200],
             'likes': c.get('digg_count', c.get('likes', 0)),
             'user': c.get('user', {}).get('uniqueId', c.get('user', {}).get('unique_id', 'anon'))}
            for c in comments]

# Get comments from top videos by engagement
top_videos = sorted(all_videos, key=lambda v: v['likes'], reverse=True)[:5]
all_comments = []
for v in top_videos:
    if v['id']:
        comments = get_comments(v['id'])
        all_comments.extend(comments)
        print(f'  @{v["author"]}: {len(comments)} comments (video: {v["likes"]:,} likes)')

print(f'Total comments: {len(all_comments)}. Cost: ${len(top_videos) * 0.005:.3f}')

Step 3: Classify sentiment from comments

Score comments by sentiment to gauge brand perception.

Python
POSITIVE = ['love', 'great', 'amazing', 'best', 'awesome', 'perfect', 'fire', 'goat',
            'recommend', 'game changer', 'saved', 'finally']
NEGATIVE = ['hate', 'terrible', 'worst', 'scam', 'trash', 'overrated', 'expensive',
            'broken', 'waste', 'disappointed', 'avoid']

def classify_comment(text):
    text_lower = text.lower()
    pos = sum(1 for w in POSITIVE if w in text_lower)
    neg = sum(1 for w in NEGATIVE if w in text_lower)
    if pos > neg: return 'positive'
    if neg > pos: return 'negative'
    return 'neutral'

def sentiment_analysis(comments):
    sentiments = Counter()
    examples = {'positive': [], 'negative': [], 'neutral': []}
    for c in comments:
        sentiment = classify_comment(c['text'])
        sentiments[sentiment] += 1
        if len(examples[sentiment]) < 3:
            examples[sentiment].append(c['text'][:80])
    total = len(comments)
    print(f'\nSentiment Analysis ({total} comments):')
    for sent in ['positive', 'negative', 'neutral']:
        pct = sentiments[sent] / total * 100 if total else 0
        print(f'  {sent}: {sentiments[sent]} ({pct:.0f}%)')
        for ex in examples[sent][:2]:
            print(f'    "{ex}"')
    return dict(sentiments)

sentiment_analysis(all_comments)

Step 4: Generate daily social listening digest

Combine video mentions and comment sentiment into a daily report.

Python
def daily_digest(brand_terms):
    print(f'\n=== TikTok Social Listening Digest - {datetime.now().strftime("%Y-%m-%d")} ===')
    all_videos = []
    cost = 0
    for term in brand_terms:
        videos = search_tiktok(term)
        all_videos.extend(videos)
        cost += 0.005
    # Deduplicate
    seen = set()
    unique = [v for v in all_videos if v['id'] not in seen and not seen.add(v['id'])]
    print(f'\nVideos found: {len(unique)} (from {len(brand_terms)} searches)')
    total_plays = sum(v['plays'] for v in unique)
    total_likes = sum(v['likes'] for v in unique)
    print(f'Total reach: {total_plays:,} plays, {total_likes:,} likes')
    # Top videos
    top = sorted(unique, key=lambda v: v['plays'], reverse=True)[:5]
    print(f'\nTop mentions:')
    for v in top:
        print(f'  @{v["author"]:20} | {v["plays"]:>10,} plays | {v["desc"][:40]}')
    # Comments from top videos
    all_comments = []
    for v in top[:3]:
        if v['id']:
            comments = get_comments(v['id'])
            all_comments.extend(comments)
            cost += 0.005
    if all_comments:
        sentiment_analysis(all_comments)
    print(f'\nDigest cost: ${cost:.3f}')

daily_digest(BRAND_TERMS)

Python Example

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

def listen(brand):
    data = requests.post('https://api.scavio.dev/api/v1/tiktok/search/videos',
        headers=TH, json={'query': brand}).json()
    videos = data.get('videos', data.get('data', {}).get('videos', []))
    print(f'{brand}: {len(videos)} TikTok mentions')
    for v in videos[:3]:
        print(f'  @{v.get("author", {}).get("uniqueId", "?")}: {v.get("desc", "")[:40]} ({v.get("stats", {}).get("playCount", 0):,} plays)')
    print(f'Cost: $0.005')

listen('serp api')

JavaScript Example

JavaScript
const TH = { 'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json' };
async function listen(brand) {
  const data = await fetch('https://api.scavio.dev/api/v1/tiktok/search/videos', {
    method: 'POST', headers: TH, body: JSON.stringify({ query: brand })
  }).then(r => r.json());
  const videos = data.videos || data.data?.videos || [];
  console.log(`${brand}: ${videos.length} TikTok mentions`);
  videos.slice(0, 3).forEach(v =>
    console.log(`  @${v.author?.uniqueId || '?'}: ${(v.desc || '').slice(0, 40)}`));
}
listen('serp api').catch(console.error);

Expected Output

JSON
  "scavio": 5 videos found
  "serp api": 12 videos found
  "search api": 8 videos found
Total: 25 videos. Cost: $0.015

=== TikTok Social Listening Digest - 2026-05-19 ===
Videos found: 20 (from 3 searches)
Total reach: 450,000 plays, 32,000 likes

Top mentions:
  @devtools_review     |    120,000 plays | Best SERP APIs ranked for developers
  @startup_hacks       |     89,000 plays | I replaced my web scraper with this

Sentiment Analysis (45 comments):
  positive: 28 (62%)
    "This is exactly what I needed for my project"
  negative: 5 (11%)
  neutral: 12 (27%)

Digest cost: $0.030

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.

Python 3.8+. requests library. A Scavio API key from scavio.dev. Brand terms and keywords to monitor. 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 for brand mentions, video comments, and sentiment signals. Daily pipeline using Scavio TikTok API at $0.005/call.