# How to export Douyin video comments in bulk

> Search Douyin by keyword, then pull the comments under each video page by page into one table: the two endpoints, the parameters, Python code and what a run costs.

Canonical page: https://okdata.online/guides/douyin-video-comments/

Two endpoints do it: Douyin video search, then Douyin video comments for each video you keep. The worked example below is 9 calls and costs $0.036; a failed call is not charged.

Updated 2026-11-12

The job: you have a topic or a product name, and you want to know what people say under the Douyin videos about it. Search first, keep the videos that drew the most discussion, then read their comment sections a page at a time. You end with one table of comments, each with its text, the commenter, likes, reply count, time and, where Douyin shows it, the commenter's IP region.

No Douyin account, cookie or signature code is involved. Each call is an HTTPS request with your key.

## Step by step

### Step 1: find the videos

Call [Douyin video search](https://okdata.online/apis/douyin/videos/search/) with `query` set to the words you would type into the Douyin search box. `sort` takes `relevance` (the default), `latest` or `most_liked`. One call returns about 20 videos, each with `id`, the caption in `text`, the author and `metrics` (likes, comments, shares, favorites). `metrics.comments` tells you which videos are worth opening.

```bash
curl -G "https://api.okdata.online/v1/douyin/videos/search" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'query=露营' \
  --data-urlencode 'sort=most_liked' \
  --data-urlencode 'fields=id,text,author.name,metrics.comments,published_at'
```

`fields` keeps only the fields you name. It does not change the price ($0.02 per call), but it keeps the response short when a model reads it.

### Step 2: read the comments under each video

Pass a video's `id` to [Douyin video comments](https://okdata.online/apis/douyin/videos/comments/list/). One call returns about 20 top-level comments for $0.002. Each one has `text`, `author`, `likes`, `replies` (how many replies sit under it), `published_at` and `ip_location`. For the next page, send `page.next_cursor` back as `cursor`, unchanged; stop when `page.has_more` is `false`.

```bash
curl -G "https://api.okdata.online/v1/douyin/videos/comments/list" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'id=7301234567890123456'
```

### Step 3: put it together in Python

The script below searches once, keeps the 8 videos with the most comments, reads up to `MAX_PAGES` pages under each and writes a CSV. Every page is its own call, so the page cap is also your spending cap.

```python
import csv
import os
import requests

API = "https://api.okdata.online"
HEADERS = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
MAX_PAGES = 1  # pages of comments per video; each page is one call


def get(path, **params):
    body = requests.get(API + path, headers=HEADERS, params=params, timeout=60).json()
    if body["code"] != "ok":
        raise RuntimeError(f"{body['code']}: {body['message']} (charged: {body['charged']})")
    return body


videos = get("/v1/douyin/videos/search", query="露营")["data"]["items"]
videos = sorted(videos, key=lambda v: v["metrics"]["comments"] or 0, reverse=True)[:8]

with open("douyin_comments.csv", "w", newline="", encoding="utf-8") as f:
    out = csv.writer(f)
    out.writerow(["video_id", "comment", "user", "likes", "replies", "ip_location", "published_at"])
    for v in videos:
        cursor = None
        for _ in range(MAX_PAGES):
            params = {"id": v["id"], **({"cursor": cursor} if cursor else {})}
            body = get("/v1/douyin/videos/comments/list", **params)
            for c in body["data"]["items"]:
                out.writerow([v["id"], c["text"], c["author"]["name"], c["likes"], c["replies"], c["ip_location"], c["published_at"]])
            if not body["page"]["has_more"]:
                break
            cursor = body["page"]["next_cursor"]
```

Raise `MAX_PAGES` to go deeper. Five pages under each of the 8 videos is 40 comment calls, $0.08 on top of the search.

## Good to know

- **Retries without paying twice.** Send an `Idempotency-Key` header (any random string you keep) with each call. If the network drops and you send the same request with the same key within 24 hours, you get the stored answer back with `meta.replayed: true` and no new charge.
- **Deleted videos are free.** A video that no longer exists returns `not_found` and costs nothing; skip it and move on.
- **Counts can differ.** Douyin folds some comments, so the number you collect can be lower than `metrics.comments` on the video.
- **Replies.** You get each comment's reply count, not the reply text. Sort by `replies` to see which comments started a conversation, then open those videos in the app if you need the thread.
- **Sorting.** Douyin's comment list comes in its own "hot" order; there is no newest-first option for comments.

For the opinions inside the comments, see [how to turn Douyin comments into a sentiment summary](https://okdata.online/answers/douyin-export-comments-sentiment/). For one account's videos rather than a keyword, start from [Douyin account videos](https://okdata.online/apis/douyin/users/videos/list/) instead of search.

## What the example costs

One page of search results for 露营 (camping), then the first page of comments under the 8 videos with the most comments

| Endpoint | Calls | Price | Subtotal |
|---|---|---|---|
| [Douyin video search](https://okdata.online/apis/douyin/videos/search/) | 1 | $0.02 | $0.02 |
| [Douyin video comments](https://okdata.online/apis/douyin/videos/comments/list/) | 8 | $0.002 | $0.016 |
| Total | 9 |  | $0.036 |

Prices in force when this page was built. A failed call costs nothing.

## In your AI (MCP)

Connect the MCP server once, then say what you want. The agent finds these endpoints, reads their prices and calls them on your balance.

Say: Search Douyin for 露营 (camping), take the 8 videos with the most comments, get the first page of comments under each and give me one table: video, comment, likes, replies, time.

```json
{
  "endpoint": "douyin.videos.search",
  "params": {
    "query": "露营装备"
  },
  "idempotency_key": "<a new UUID>"
}
```

MCP: `https://api.okdata.online/mcp`

## Endpoints in this guide

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

## More about Douyin

- [Douyin API](https://okdata.online/apis/douyin/)
- [Douyin API in Python: videos, profiles and comments (2026)](https://okdata.online/guides/douyin-api-python/)
- [How to find Douyin Xingtu creators and get their rate cards](https://okdata.online/guides/douyin-xingtu-creator-rates/)
- [Do I need residential proxies to scrape Douyin or TikTok, and what do they cost?](https://okdata.online/answers/do-i-need-proxies-for-social-media-scraping/)
- [What is Douyin's a_bogus parameter, and do I need to generate it to get Douyin data?](https://okdata.online/answers/douyin-a-bogus-signature/)
- [How do I get the IP location of Douyin commenters and count them by province?](https://okdata.online/answers/douyin-comment-ip-location/)
- [How do I export Douyin video comments for sentiment analysis?](https://okdata.online/answers/douyin-export-comments-sentiment/)
- [How do I monitor brand mentions on Douyin and get new videos every day?](https://okdata.online/answers/douyin-keyword-monitoring/)
- [Why do some Douyin links say /note/ instead of /video/?](https://okdata.online/answers/douyin-note-vs-video-links/)
- [How to collect Douyin comments: API, crawler or no-code (2026)](https://okdata.online/compare/douyin-comment-scraping/)
- [Douyin data APIs: official vs third-party vs open-source (2026)](https://okdata.online/compare/douyin-data-apis/)
- [Official platform APIs vs third-party data APIs (2026)](https://okdata.online/compare/official-apis-vs-data-apis/)
- [Scraping it yourself vs a per-call data API: cost, upkeep and risk](https://okdata.online/compare/scraping-vs-data-api/)
- [How to choose a social media data API (2026)](https://okdata.online/compare/social-media-data-apis/)
