# How do I export Douyin video comments for sentiment analysis?

> Pull every top-level comment on Douyin videos with an API, save text, likes, replies, time and IP location to CSV, and prepare it for sentiment analysis. Cost per 1,000.

Canonical page: https://okdata.online/answers/douyin-export-comments-sentiment/

**Short answer: **Call the okdata Douyin video comments endpoint with each video ID and follow the cursor; a page of about 20 comments costs $0.002, so 1,000 comments take 50 calls and cost $0.10. Each comment has text, likes, reply count, time and IP location, ready for a sentiment model.

A product team launched a new phone case and wants to know how Douyin viewers react: what they praise, what they mock, which regions care. The raw material is the comment sections of the 30 biggest videos about it, a few thousand comments. Scrapers often get only the caption, or block with "account blocked" halfway through. The API route is three steps.

## 1. Pick the videos

Use [Douyin video search](/apis/douyin/videos/search/) with `sort=most_liked`, or turn known share links into IDs with [video detail](/apis/douyin/videos/get/). Each video's `metrics.comments` tells you how big its comment section is.

## 2. Pull the comments

[Douyin video comments](/apis/douyin/videos/comments/list/) takes the video `id` and an optional `sort` (`hot` or `latest`). Each comment has `text`, `published_at`, `likes`, `replies` (the number of replies under it), `ip_location` (the province Douyin shows) and the commenter.

## 3. Score them

Clean the text, then run a sentiment model or an LLM with a fixed label set, and weight each comment by its likes: a complaint with 2,000 likes speaks for more people than one with none.

## Cost

| Job | Calls | Cost |
|---|---|---|
| Find 40 videos | 2 search pages | $0.04 |
| 30 videos × 5 comment pages | 150 | $0.30 |
| 1,000 comments, any video | 50 | $0.10 |

## Script

```python
import csv, os, requests

URL = "https://api.okdata.online/v1/douyin/videos/comments/list"
HEAD = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}

with open("douyin_comments.csv", "w", newline="", encoding="utf-8-sig") as f:
    w = csv.writer(f)
    w.writerow(["video_id", "published_at", "text", "likes", "replies", "ip_location"])
    for vid in ["7301234567890123456"]:
        params = {"id": vid, "sort": "hot"}
        for _ in range(5):
            body = requests.get(URL, headers=HEAD, params=params, timeout=60).json()
            for c in body["data"]["items"]:
                w.writerow([vid, c["published_at"], c["text"], c["likes"], c["replies"], c["ip_location"]])
            if not body["page"]["has_more"]:
                break
            params["cursor"] = body["page"]["next_cursor"]
```

## Before you score

- Douyin writes emoji as codes like `[捂脸]` or `[赞]` inside the text. Map them to sentiment hints or strip them; many models misread them.
- Top-level comments only. The video's comment counter also counts replies, so you will collect fewer rows than it shows; `replies` tells you where the long threads are.
- Short comments ("哈哈哈", "求链接") are common. Decide up front whether purchase-intent comments count as positive.
- IP location is the province Douyin displays, not a precise location.

## Alternatives

For one video, scrolling and copying is fine. MediaCrawler and similar tools collect comments and replies with a logged-in account. Social listening suites score sentiment for you but cost far more per month. The [word-of-mouth](/solutions/word-of-mouth/) page shows the full report, including Xiaohongshu and Weibo.

## Endpoints used

- [Douyin video comments](https://okdata.online/apis/douyin/videos/comments/list/) `douyin.videos.comments.list`: $0.002 per call · about 20 comments per page
- [Douyin video detail](https://okdata.online/apis/douyin/videos/get/) `douyin.videos.get`: $0.002 per call
- [Douyin video search](https://okdata.online/apis/douyin/videos/search/) `douyin.videos.search`: $0.02 per call · about 20 videos per page

Updated 2026-11-12
