TikTok Comment Sentiment for Brand Monitoring via API
Pull video comments via TikTok API, run sentiment analysis, and detect brand mentions. At $0.005 per comments request and 1 credit each, monitoring a creator's video for brand signals costs a few cents per video checked. At this price, TikTok comment data is accessible for any brand budget.
What Comment Data Reveals That View Count Does Not
View count tells you reach. Comment sentiment tells you reaction. A video with 500k views and comments that are 80% negative has a different brand impact than the same video with 80% positive comments. For brands that sponsor creators or appear in viral content, comment sentiment is the downstream measure that matters.
Comment monitoring use cases:
- A brand's sponsored video: is the audience responding positively or calling out the sponsorship?
- A competitor's product review: what specific features are customers criticizing?
- An organic mention of your brand in a creator's video: is it positive buzz or complaint-amplification?
Fetching and Analyzing Comments
import requests
import anthropic
from collections import Counter
client = anthropic.Anthropic()
def fetch_comments(video_id: str, count: int = 50) -> list[dict]:
resp = requests.post(
"https://api.scavio.dev/api/v1/tiktok/video_comments",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"video_id": video_id, "count": count}
)
return resp.json().get("comments", [])
def analyze_comments(comments: list[dict], brand: str) -> dict:
comment_texts = [c.get("text", "") for c in comments if c.get("text")]
if not comment_texts:
return {"error": "no comments"}
# Weight by likes (high-liked comments carry more signal)
weighted = sorted(
[(c.get("text"), c.get("digg_count", 0)) for c in comments if c.get("text")],
key=lambda x: x[1], reverse=True
)
top_comments = [t for t, _ in weighted[:20]]
prompt = f"""Analyze these TikTok comments for mentions of '{brand}'.
For each comment that mentions {brand}, classify as:
- positive: favorable mention or praise
- negative: criticism or complaint
- neutral: factual mention without clear sentiment
Also identify the 3 most common themes in ALL comments (not just brand mentions).
Comments:
{chr(10).join(top_comments)}
Return JSON: {{
"brand_mentions": [{{"text": "...", "sentiment": "positive/negative/neutral"}}],
"overall_sentiment": "positive/mixed/negative",
"top_themes": ["theme1", "theme2", "theme3"],
"brand_mention_count": 0
}}"""
resp = client.messages.create(
model="claude-haiku-4-5",
max_tokens=500,
messages=[{"role": "user", "content": prompt}]
)
import json
return json.loads(resp.content[0].text)Cost: 1 credit ($0.005) for the comments fetch + ~$0.0002 for Haiku analysis. Total: ~$0.005 per video monitored.
Finding Videos That Mention Your Brand
Before analyzing comments, you need to find the relevant videos:
def find_brand_videos(brand: str, count: int = 10) -> list[str]:
# Search TikTok for videos mentioning brand
resp = requests.post(
"https://api.scavio.dev/api/v1/tiktok/search_videos",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"keyword": brand, "count": count}
)
videos = resp.json().get("videos", [])
return [v["id"] for v in videos if v.get("id")]1 search call + 1 comments call per video = 2 credits per video = $0.01 to analyze comment sentiment for any video mentioning your brand.
Prioritizing Which Videos to Analyze
Not all brand mentions deserve comment analysis. Prioritize:
- High view count videos: more reach means comment sentiment has higher impact
- Videos with high comment volume: more comments = richer signal
- Videos from accounts with large followings: an influencer's opinion reaches more potential customers
- Recently posted videos: the comment section is most active in the first 24-48 hours
def prioritize_for_analysis(videos: list[dict]) -> list[dict]:
scored = []
for v in videos:
score = (
v.get("play_count", 0) * 0.01 + # views weighted lightly
v.get("comment_count", 0) * 10 + # comments weighted heavily
v.get("author", {}).get("follower_count", 0) * 0.001
)
scored.append({**v, "priority_score": score})
return sorted(scored, key=lambda x: x["priority_score"], reverse=True)Analyze the top 5 highest-priority videos daily for a brand. Cost: 10 API calls + 5 Haiku analyses = 10 credits + minimal LLM cost = $0.05/day = $1.50/month.