Douyin comments API for sentiment analysis: which endpoints, what it costs
Three endpoints are enough: douyin_keyword_search finds videos, douyin_video_comments pulls the comments, douyin_video_detail adds engagement so you know which videos are worth pulling. ¥0.1–0.2 per call, failed calls are never charged. 500 videos × 6 comment pages ≈ ¥700.
Which endpoints to call
| Endpoint | Price | Calls | Subtotal | Purpose |
|---|---|---|---|---|
douyin_keyword_search | ¥0.1 | ×1 | ¥0.1 | Find candidate videos by keyword; returns aweme_id |
douyin_video_detail | ¥0.1 | ×1 | ¥0.1 | Engagement metrics, to decide which videos are worth comments |
douyin_video_comments | ¥0.2 | ×6 | ¥1.2 | Pull comments by aweme_id (cursor is page) |
| per video (1 search + 1 detail + 6 comment pages) | ¥1.4 | per full run | ||
| 500 videos | ¥700 | 500 × ¥1.4 | ||
Working code skeleton
Runs as-is once you set TOKEN. Failed and empty calls are skipped, so they cost nothing.
import time, requests
TOKEN, API = "fw_xxx", "https://finewisdom.top/api"
def call(method, **params):
r = requests.get(API, params={"token": TOKEN, "method": method, **params}, timeout=60).json()
if r.get("status") != "success":
print("skip:", method, r.get("message")) # failed calls are not charged
return None
return r["data"]
def comments_of(aweme_id, max_pages=6):
out = []
for page in range(max_pages):
d = call("douyin_video_comments", aweme_id=aweme_id, page=page)
if not d:
break
batch = d.get("comments") or d.get("list") or []
if not batch:
break # empty result is free, stop early
out.extend(batch)
time.sleep(1.1) # rate limit is 1 request/second
return out
def run(keyword):
found = call("douyin_keyword_search", keyword=keyword, page=0)
videos = found.get("list") or found.get("aweme_list") or []
rows = []
for v in videos[:500]:
aid = v.get("aweme_id")
detail = call("douyin_video_detail", aweme_id=aid)
rows.extend({
"keyword": keyword,
"aweme_id": aid,
"like": (detail or {}).get("like") or v.get("like"),
"text": c.get("text") or c.get("content"),
} for c in comments_of(aid))
return rows
Gotchas worth knowing
- The Douyin search endpoint returns
code: falseplus a message when there are no results. Treat that as a failure, not as an empty list — otherwise your incremental job will silently stop retrying for the rest of the day. - Comment pagination depth is capped by what the platform exposes (usually tens of pages). No third-party API can go beyond that; if you need history, persist it yourself and append daily.
- Rate limit is 1 request/second/IP. Batch jobs must run serially with
sleep(1.1); 50 concurrent requests will just get you a wall of 429s.
FAQ
Can I pull all comments for a keyword directly?
No. You search first to get content IDs, then pull comments by ID. The comment endpoint takes a content ID — there is no keyword-to-comments shortcut.
Why call the detail endpoint first?
Detail returns likes/comments/plays, which lets you skip low-value videos before spending money on comment pages. That typically halves the bill.