Tutorial

How to Build a TikTok Brand Monitoring Pipeline

Monitor brand mentions on TikTok with automated search and comment analysis. Python pipeline using Scavio API + LLM sentiment.

Build a TikTok brand monitoring pipeline that searches for brand mentions, extracts comments from relevant videos, and classifies sentiment. Total cost: $0.25-0.50/day for monitoring 10 brand keywords.

Prerequisites

  • Scavio API key
  • Python 3.8+
  • Optional: OpenAI API key for sentiment
  • Notification channel (Slack webhook, email)

Walkthrough

Step 1: Search for brand mentions

Search TikTok videos mentioning your brand.

Python
import requests, os

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

def search_brand(brand_name, 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_name, 'count': 20, 'cursor': cursor}).json()['data']
        videos.extend(data.get('videos', []))
        if not data.get('has_more'): break
        cursor = data['cursor']
    return videos

Step 2: Extract comments from high-engagement videos

Pull comments from videos that got significant engagement.

Python
def get_comments(video_id, pages=2):
    comments = []
    cursor = 0
    for _ in range(pages):
        data = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
            headers=HEADERS,
            json={'aweme_id': video_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

# Only analyze videos with significant engagement
high_engagement = [v for v in videos if v['stats']['playCount'] > 1000]
for v in high_engagement[:5]:
    comments = get_comments(v['id'])
    print(f"{v['desc'][:40]}: {len(comments)} comments")

Python Example

Python
import requests, os, json
from datetime import date

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

def brand_monitor(brand, keywords=None):
    if keywords is None:
        keywords = [brand, f'{brand} review', f'{brand} alternative']
    report = {'date': date.today().isoformat(), 'brand': brand, 'mentions': []}
    for kw in keywords:
        data = requests.post('https://api.scavio.dev/api/v1/tiktok/search/videos',
            headers=HEADERS,
            json={'keyword': kw, 'count': 20, 'cursor': 0}).json()['data']
        for v in data.get('videos', []):
            if v['stats']['playCount'] > 500:
                report['mentions'].append({
                    'keyword': kw, 'desc': v['desc'][:100],
                    'plays': v['stats']['playCount'],
                    'likes': v['stats']['diggCount'],
                    'comments': v['stats']['commentCount'],
                })
    report['total_mentions'] = len(report['mentions'])
    return report

report = brand_monitor('mybrand')
print(f"{report['total_mentions']} high-engagement mentions found")

JavaScript Example

JavaScript
const H = {'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json'};
async function brandMonitor(brand) {
  const keywords = [brand, `${brand} review`, `${brand} alternative`];
  const mentions = [];
  for (const kw of keywords) {
    const r = await fetch('https://api.scavio.dev/api/v1/tiktok/search/videos', {
      method: 'POST', headers: H,
      body: JSON.stringify({keyword: kw, count: 20, cursor: 0})
    }).then(r => r.json());
    (r.data.videos || []).filter(v => v.stats.playCount > 500).forEach(v =>
      mentions.push({keyword: kw, desc: v.desc?.slice(0, 100),
        plays: v.stats.playCount, likes: v.stats.diggCount})
    );
  }
  console.log(`${mentions.length} high-engagement mentions found`);
  return mentions;
}
brandMonitor('mybrand');

Expected Output

JSON
Daily brand monitoring report with high-engagement TikTok mentions, engagement metrics, and optional sentiment classification.

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.

Scavio API key. Python 3.8+. Optional: OpenAI API key for sentiment. Notification channel (Slack webhook, email). 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 brand mentions on TikTok with automated search and comment analysis. Python pipeline using Scavio API + LLM sentiment.