ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Extract Brand Signals from TikTok Comments
Tutorial

How to Extract Brand Signals from TikTok Comments

Mine TikTok comments for brand mentions, purchase intent, and product questions. Python pipeline at $0.005/call.

Get Free API KeyAPI Docs

TikTok comments contain unfiltered brand sentiment: users asking 'where can I buy this', mentioning competitors, or complaining about features. This tutorial builds a comment mining pipeline using Scavio's video/comments endpoint to extract purchase intent, brand mentions, and product feedback at scale.

Prerequisites

  • Python 3.8+
  • requests library
  • A Scavio API key from scavio.dev
  • TikTok video IDs to analyze

Walkthrough

Step 1: Fetch comments from a video

Pull comments with pagination.

Python
import os, requests, re
from collections import Counter

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

def get_comments(video_id, pages=3):
    comments = []
    params = {'video_id': video_id, 'count': 20}
    for _ in range(pages):
        resp = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
            headers=H, json=params).json()['data']
        for c in resp.get('comments', []):
            comments.append({'text': c.get('text', ''), 'likes': c.get('digg_count', 0)})
        if not resp.get('has_more'): break
        params['cursor'] = resp.get('cursor', 0)
    return comments

Step 2: Detect brand mentions and intent

Scan for brand names and buying signals.

Python
BRANDS = ['scavio', 'serpapi', 'exa', 'tavily']
INTENT = ['where to buy', 'link', 'how much', 'price', 'worth it', 'recommend']

def analyze(text):
    t = text.lower()
    return {
        'brands': [b for b in BRANDS if b in t],
        'intent': [s for s in INTENT if s in t],
        'negative': any(w in t for w in ['scam', 'fake', 'waste', 'terrible']),
    }

Step 3: Aggregate across videos

Analyze multiple videos and produce a summary.

Python
def report(video_ids):
    for vid in video_ids:
        comments = get_comments(vid)
        mentions = Counter()
        intent_count = 0
        for c in comments:
            a = analyze(c['text'])
            for b in a['brands']: mentions[b] += 1
            if a['intent']: intent_count += 1
        print(f'Video {vid}: {len(comments)} comments')
        print(f'  Brands: {dict(mentions)}')
        print(f'  Intent signals: {intent_count}')
    print(f'Cost: ${len(video_ids) * 3 * 0.005:.3f}')

report(['vid1', 'vid2'])

Step 4: Export timeline data

Track brand signals over time.

Python
import json
from datetime import date

def export(video_ids, output='signals.jsonl'):
    with open(output, 'a') as f:
        for vid in video_ids:
            comments = get_comments(vid, pages=2)
            mentions = Counter()
            for c in comments:
                for b in analyze(c['text'])['brands']: mentions[b] += 1
            f.write(json.dumps({'date': date.today().isoformat(), 'video': vid,
                'mentions': dict(mentions), 'total': len(comments)}) + '\n')
    print(f'Exported {len(video_ids)} videos')

export(['vid1'])

Python Example

Python
import os, requests
from collections import Counter
API_KEY = os.environ['SCAVIO_API_KEY']
H = {'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'}
BRANDS = ['scavio', 'serpapi', 'exa']

def analyze(video_id):
    resp = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
        headers=H, json={'video_id': video_id, 'count': 20}).json()
    mentions = Counter()
    for c in resp['data'].get('comments', []):
        for b in BRANDS:
            if b in c.get('text', '').lower(): mentions[b] += 1
    print(f'{video_id}: {dict(mentions)}')

analyze('sample_id')

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY;
const H = { Authorization: `Bearer ${API_KEY}`, 'Content-Type': 'application/json' };
async function analyze(videoId) {
  const resp = await fetch('https://api.scavio.dev/api/v1/tiktok/video/comments', {
    method: 'POST', headers: H, body: JSON.stringify({ video_id: videoId, count: 20 })
  }).then(r => r.json());
  const mentions = {};
  for (const c of resp.data.comments || []) {
    for (const b of ['scavio', 'serpapi']) if (c.text?.toLowerCase().includes(b)) mentions[b] = (mentions[b]||0)+1;
  }
  console.log(`${videoId}:`, mentions);
}
analyze('sample_id').catch(console.error);

Expected Output

JSON
Video vid1: 58 comments
  Brands: {'scavio': 3, 'serpapi': 1}
  Intent signals: 8
Video vid2: 42 comments
  Brands: {'exa': 2}
  Intent signals: 5
Cost: $0.030

Related Tutorials

  • How to Get TikTok Video Comments via API
  • How to Monitor TikTok Brand Mentions via API
  • How to Build a TikTok Influencer Vetting Pipeline

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. TikTok video IDs to analyze. A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, 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.

Related Resources

Use Case

TikTok Comment Signals

Read more
Best Of

Best TikTok Comment Analytics Tools in 2026

Read more
Best Of

Best YouTube Sentiment Analysis Tools in 2026

Read more
Solution

Extract Brand Signals from TikTok Comments

Read more
Glossary

TikTok Comment Sentiment

Read more
Use Case

TikTok Comment Sentiment for Product Feedback

Read more

Start Building

Mine TikTok comments for brand mentions, purchase intent, and product questions. Python pipeline at $0.005/call.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy