Our Douyin API returns a public video's comments as JSON, up to 20 per call, with each comment's text, time, likes, reply count and the province or country Douyin shows next to it. Paste the video link; the script below writes up to 10 pages per video to a CSV in under a minute.
What one call returns
We make ToolzerHub. Our Douyin API reads public Douyin pages; /v2/douyin/videos/comments takes a video id or any douyin.com video link and costs 2 credits a call.
export TOOLZERHUB_API_KEY=your_key
curl -H "x-api-key: $TOOLZERHUB_API_KEY" \
"https://api.toolzerhub.com/v2/douyin/videos/comments?aweme_id=7433051315128896802"
One comment on a Luckin Coffee video, trimmed:
{
"cursor": 20,
"has_more": 1,
"total": 7689,
"comments": [{
"cid": "7674953277570515712",
"text": "情人节没有比这更恩爱的了",
"create_time": 1786964313,
"digg_count": 163,
"reply_comment_total": 9,
"ip_label": "湖北",
"is_author_digged": false
}]
}
ip_label is the province, or the country for commenters abroad, that Douyin displays under the comment. is_author_digged is Douyin's flag for a like from the video's account. Pass cursor back to get the next 20. The response also carries the commenter's public profile; the script below leaves it out.
Read the replies under a comment
Replies come from /v2/douyin/videos/comments/replies, which takes the video and the parent comment's cid, at 2 credits per page of 20. The comment above shows reply_comment_total: 9, and one call returned all 9:
curl -H "x-api-key: $TOOLZERHUB_API_KEY" \
"https://api.toolzerhub.com/v2/douyin/videos/comments/replies?aweme_id=7433051315128896802&comment_id=7674953277570515712"
The first reply, trimmed:
{
"cid": "7674966318096958257",
"text": "人家瑞幸看不起一二布布 再也不喝了",
"digg_count": 32,
"ip_label": "江苏",
"reply_id": "7674953277570515712",
"reply_to_reply_id": "0"
}
reply_id is the parent comment. reply_to_reply_id is 0 for a direct reply and holds a reply's cid when someone answers inside the thread, so you can rebuild the conversation. Most comments have no replies, so read them only where replies in the CSV is above 0.
Export Douyin comments to CSV
The script takes video links, reads up to the number of pages you ask for and writes one row per comment, keeping each cid once. For each video it prints how many comments it saved, the top three provinces and the most-liked comment. Install requests (pip install requests) and save it as douyin_comments.py.
import collections
import csv
import os
import sys
import time
from datetime import datetime, timezone
import requests
URL = "https://api.toolzerhub.com/v2/douyin/videos/comments"
HEADERS = {"x-api-key": os.environ.get("TOOLZERHUB_API_KEY", "")}
FIELDS = ["video", "cid", "posted_at", "likes", "replies", "province", "liked_by_author", "text"]
def get_page(video, cursor, tries=3):
# Retry rate limits, server errors and dropped connections.
params = {"aweme_id": video, "cursor": cursor}
for attempt in range(tries):
last = attempt == tries - 1
try:
r = requests.get(URL, headers=HEADERS, params=params, timeout=120)
except requests.RequestException:
if last:
raise
time.sleep(5 * (attempt + 1))
continue
if r.status_code in (429, 500, 502, 503, 504) and not last:
time.sleep(5 * (attempt + 1))
continue
r.raise_for_status()
return r.json()["data"]
def main(videos, pages="10", out="douyin_comments.csv"):
with open(out, "w", newline="", encoding="utf-8-sig") as f:
writer = csv.DictWriter(f, fieldnames=FIELDS)
writer.writeheader()
for video in filter(None, (v.strip() for v in videos.split(","))):
comments, seen, cursor, total = [], set(), 0, None
for _ in range(int(pages)):
data = get_page(video, cursor)
total = data.get("total")
comments += [c for c in data.get("comments") or [] if c["cid"] not in seen]
seen.update(c["cid"] for c in data.get("comments") or [])
if not data.get("has_more"):
break
cursor = data["cursor"]
for c in comments:
writer.writerow({
"video": video, "cid": c["cid"],
"posted_at": datetime.fromtimestamp(c["create_time"], timezone.utc).isoformat(),
"likes": c["digg_count"], "replies": c.get("reply_comment_total") or 0,
"province": c.get("ip_label") or "", "liked_by_author": c.get("is_author_digged", False),
"text": c["text"],
})
provinces = collections.Counter(c.get("ip_label") or "unknown" for c in comments)
top = max(comments, key=lambda c: c["digg_count"]) if comments else None
print(f"{video}: {len(comments)} of {total} comments; "
f"{sum(bool(c.get('is_author_digged')) for c in comments)} liked by the author; "
f"top provinces {', '.join(f'{p} {n}' for p, n in provinces.most_common(3))}"
+ (f"; most liked: {top['text'][:30]} ({top['digg_count']:,})" if top else ""))
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.exit("usage: python douyin_comments.py <video links or ids, comma-separated> [pages] [out.csv]")
if not HEADERS["x-api-key"]:
sys.exit("set TOOLZERHUB_API_KEY first")
main(*sys.argv[1:])
The CSV is UTF-8 with a byte-order mark, so Excel opens the Chinese text correctly.
What came out
The most-commented of the latest 60 videos from Mixue, Huawei and Xiaomi, 10 pages each, made 30 calls in 59 seconds and saved 495 unique comments:
python douyin_comments.py "https://www.douyin.com/video/7674093726343433498,https://www.douyin.com/video/7691361441814711579,https://www.douyin.com/video/7688716184884512249" 10
| Video | Comments on Douyin | Saved | Most-liked comment's likes | Top province |
|---|---|---|---|---|
| Mixue | 18,078 | 129 | 31,725 | 广东 (Guangdong), 23 |
| Huawei Mate 90 RS | 6,748 | 180 | 459 | 四川 (Sichuan), 23 |
| Xiaomi 18 Pro | 6,288 | 186 | 10 | 广东 (Guangdong), 39 |
The 495 comments came from 33 provinces, regions and countries, led by Guangdong with 76 and Jiangsu with 48. The median comment had no likes. On the Mixue video one question, asking whether a drink tastes good, had 31,725 likes; the next had 9. None of the 495 was liked by the brand's account. Replies are rare too: 21 of the Mixue comments, 12 of Xiaomi's and 3 of Huawei's had any, so reading every thread would add at least 36 calls.
What it costs
A page of 20 comments is 2 credits, so 10 pages on a video are 20 credits. The 100 free credits a month cover five videos at that depth; $19 buys 10,000 credits that never expire, and plans for higher volume cover tracking a brand's videos every week. Set your key and the first video is a CSV in under a minute.
To find the videos first, see does Douyin have an API. For the same job on RedNote, see export a RedNote account's notes.
We are not affiliated with Douyin or ByteDance.