Page through /v1/video/comments with the video link, following cursor until has_more is false, and write each comment’s cid, author_unique_id, digg_count, create_time and text to a CSV file with Python’s csv module. Excel and Google Sheets open the file directly.
The script
import csv, datetime
import os, requests
API = "https://api.tikultra.com"
HEADERS = {"x-api-key": os.environ["TIKULTRA_API_KEY"]}
def get(path, **params):
r = requests.get(API + path, headers=HEADERS, params=params, timeout=60)
r.raise_for_status()
return r.json()
def comments(link):
cursor = None
while True:
page = get("/v1/video/comments", url=link, **({"cursor": cursor} if cursor else {}))
yield from page["comments"]
if not page.get("has_more"):
break
cursor = page["cursor"]
link = "https://www.tiktok.com/@tiktok/video/7693184538704416031"
with open("comments.csv", "w", newline="", encoding="utf-8") as f:
w = csv.writer(f)
w.writerow(["comment_id", "author", "likes", "posted_utc", "text"])
for c in comments(link):
posted = datetime.datetime.fromtimestamp(c["create_time"], datetime.timezone.utc).isoformat()
w.writerow([c["cid"], c["author_unique_id"], c["digg_count"], posted, c["text"]])Replies
Top-level comments come first. For the threads you care about, call /v1/video/comments/replies with the aweme_id and the comment_id; it pages the same way.
Sorting and cost
Pass sort_strategy=new for newest first, or leave the default (hot). Each page is 1 req; a video with 5,000 comments takes roughly 100 to 250 pages depending on page size, which is under $0.23 on Growth.