Answers

How do I export all the comments on a TikTok video to CSV or Excel?

Short answer

Page through TikTok video comments (/v1/tiktok/videos/comments/list) and write each page to a CSV. Every call returns about 50 comments for $0.002, so a video with 2,000 comments costs $0.08 and 1,000 comments cost $0.04. Each row gets the text, likes, reply count, time and commenter.

A product video of yours went viral and has 2,000 comments. Your team wants them in Excel to tag complaints, questions and feature requests, and copying them by hand stops being funny after the first hundred. The script below writes every top-level comment to a CSV in a couple of minutes.

Before you start: how many comments, and what it will cost

The comment count on the video tells you the bill in advance. TikTok video detail returns it as metrics.comments for $0.002. Then:

Comments Calls to TikTok video comments Cost
500 10 $0.02
2,000 40 $0.08
10,000 200 $0.40

The export script

It takes a video link, looks up the ID, and pages until TikTok says there is nothing more. utf-8-sig makes Excel show emoji and non-Latin text correctly.

import csv, os, sys, requests

API = "https://api.okdata.online/v1"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}

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

video = get("tiktok/videos/get", url=sys.argv[1])["data"]["item"]
print("TikTok shows", video["metrics"]["comments"], "comments")

with open(f"comments-{video['id']}.csv", "w", newline="", encoding="utf-8-sig") as f:
    w = csv.writer(f)
    w.writerow(["published_at", "author", "text", "likes", "replies", "location"])
    cursor = None
    while True:
        body = get("tiktok/videos/comments/list", id=video["id"], **({"cursor": cursor} if cursor else {}))
        for c in body["data"]["items"]:
            w.writerow([c["published_at"], c["author"]["username"], c["text"], c["likes"], c["replies"], c["ip_location"]])
        if not body["page"]["has_more"]:
            break
        cursor = body["page"]["next_cursor"]

Run it as python export.py "https://www.tiktok.com/@user/video/7305085486984858894". Short links from the share button work too.

Why the row count is lower than TikTok's number

TikTok's comment count includes replies. This endpoint returns top-level comments, each with a replies count, but not the reply text itself. Comments that TikTok has filtered or removed are not returned either. A video showing 2,000 comments often exports as fewer rows, and the difference is mostly replies.

Other details: ip_location is filled only where TikTok shows a location; each page is a separate charge; a failed page is free and can be retried with the same cursor.

Other ways

  • Copy by hand or a browser extension: fine for one video with under a hundred comments.
  • TikTokApi: free, but it drives a browser and often returns empty responses on servers.
  • TikTok Research API: has a comment endpoint, for approved academic researchers only.

To compare comments across many videos or brands, see word of mouth.

Updated