How to get the comments of a TikTok video in Python
Checked on 2026-11-19.
On TikTok for Developers, the API that returns the comments under any public video is the Research API, and it is open only to approved academic and not-for-profit researchers. Everyone else reads the comments TikTok shows publicly under the video: with an open-source library that drives a browser on your own computer, or with one request to an HTTP API.
1. The Research API: official, for approved researchers
If you qualify, this is the route to use. /v2/research/video/comment/list/ returns the comments of a video up to 100 at a time and continues with a cursor while has_more is true. Pass a comment_id instead of a video_id to read the replies to one comment. The daily limit is 1000 requests, which TikTok's FAQ puts at up to 100,000 records a day.
import os
import requests
# The client key and secret of the research client TikTok creates after approval.
token = requests.post(
"https://open.tiktokapis.com/v2/oauth/token/",
data={
"client_key": os.environ["TIKTOK_CLIENT_KEY"],
"client_secret": os.environ["TIKTOK_CLIENT_SECRET"],
"grant_type": "client_credentials",
},
timeout=30,
).json()["access_token"] # valid for 2 hours
body = {"video_id": 6718335390845095173, "max_count": 100, "cursor": 0}
while True:
page = requests.post(
"https://open.tiktokapis.com/v2/research/video/comment/list/",
params={"fields": "id,text,like_count,reply_count,parent_comment_id,create_time"},
headers={"Authorization": f"Bearer {token}"},
json=body,
timeout=30,
).json()["data"]
for comment in page["comments"]:
print(comment["like_count"], comment["text"])
if not page["has_more"]:
break
body["cursor"] = page["cursor"]The fields you can ask for are id, video_id, text, like_count, reply_count, parent_comment_id and create_time: the reference calls that the complete list. A commenter's username is not among them. TikTok's codebook says of comments: "To protect the privacy of our users, other information is removed." Phone numbers, email addresses and card numbers inside the text come back masked with asterisks.
Where it stops: at the application. You need an academic or not-for-profit affiliation in a region TikTok lists and an approved research proposal, and commercial users are excluded. The guide to Research API access has the conditions in full.
Two routes that have no comments
The Display API has three endpoints, for the profile and the videos of a user who logged in to your app. Its video object carries a comment_count and no comments. yt-dlp has a --write-comments option, but its TikTok extractor has no comment download: it fills comment_count only. Both tell you how many comments there are, not what they say.
2. The TikTokApi library: free, with a browser on your own computer
TikTokApi is an unofficial, open-source wrapper for TikTok's website. It needs Python 3.9 or newer and a Playwright browser, which it starts for its sessions. The code below is the comment example from its repository; the ms_token is a cookie value you copy from your own browser's visit to tiktok.com.
# pip install TikTokApi
# python -m playwright install
import asyncio
import os
from TikTokApi import TikTokApi
ms_token = os.environ.get("ms_token", None) # from your own cookies on tiktok.com
async def get_comments():
async with TikTokApi() as api:
await api.create_sessions(
ms_tokens=[ms_token],
num_sessions=1,
sleep_after=3,
browser=os.getenv("TIKTOK_BROWSER", "chromium"),
)
video = api.video(id=6718335390845095173)
async for comment in video.comments(count=30):
print(comment.likes_count, comment.text)
asyncio.run(get_comments())Each comment has text, likes_count, author and TikTok's raw data in as_dict. Raise count to read further down the list.
Where it breaks: the README is frank about it. An EmptyResponseException "means TikTok is blocking the request and detects you're a bot", and its answer is that "you may need a proxy", which you then have to buy and manage. It also says the codebase "can and does run into similar issues as it has before, because TikTok changes things up." It runs a real browser, which is a lot to carry on a small server or in a cloud function. For a few videos on your own machine it is a fair free choice.
3. An HTTP API: the top comments in one request
With Pipefetch the top comments of a public video are one HTTPS request with one key, from any server. It is not an official TikTok API, and Pipefetch is not affiliated with TikTok: it returns the comments TikTok shows under a public video to a visitor who is not logged in.
import os
import requests
res = requests.get(
"https://pipefetch.com/v1/tiktok/comments",
params={"video": "https://www.tiktok.com/@scout2015/video/6718335390845095173", "limit": 40},
headers={"x-api-key": os.environ["PIPEFETCH_API_KEY"]},
timeout=90,
)
if res.status_code == 404:
print("TikTok shows no comments for this video") # not charged
else:
res.raise_for_status()
data = res.json()["data"]
print(data["video"]["commentCount"], "comments in total")
for comment in data["comments"]:
print(comment["position"], comment["likeCount"], comment["replyCount"], comment["text"])Its limits, plainly:
- Up to 100 comments per video (
limit, 1 to 100, 20 when you leave it out), in TikTok's own order with the top comments first. There is no newest-first order and no further page. - Top-level comments only.
replyCountsays how many replies each one has; the replies themselves are not returned. - The price follows
limit: 1 credit per started 20 comments, so 40 are 2 credits and 100 are 5, also when the video has fewer comments than you asked for. - A video TikTok shows no comments for answers 404 and costs nothing. The code is
no_commentswhen it has none, andvideo_not_foundwhen it was deleted, is private, has comments turned off or the link is wrong. TikTok does not say which of those four it is. - A short
vm.tiktok.comlink is not accepted: open it and pass the address it leads to.
Each comment comes with its likes, date, pinned and liked-by-creator flags, and the commenter's public username and profile link. video.commentCount is the total TikTok's comment list reports. A new account has 100 free credits, and the reference lists every field.
Which one should you use?
| You need | Use |
|---|---|
| Every comment and the replies, for a study you can get approved | The Research API |
| The comments of a few videos, free, on your own computer | The TikTokApi library |
| The top comments of many videos, from a server | An HTTP API such as Pipefetch |
| More than the top 100 comments of a video, without research access | The library; Pipefetch stops at 100 |
Of the three, only the Research API is TikTok's own. The library and Pipefetch read what TikTok shows publicly, without TikTok's approval, and TikTok's Terms of Service list among the things users must not do: "extract any data or content from the Platform using any automated system or software that is not provided by TikTok or approved in writing by TikTok". If your work needs TikTok's permission in writing, apply for the Research API.
Comments are personal data
A comment read from the public page comes with its author's username. Under laws such as the GDPR that is personal data, whichever route you used to fetch it. Keep only what your purpose needs, and do not publish lists of commenters. TikTok's own Research API leaves usernames out of what it returns, which is a fair hint at how careful to be. For the numbers of the video itself, see how to get a TikTok video's views and likes.
Try it with 100 free credits. No card needed. No scraper to build or maintain. Get an API key or read the docs.
APIs used in this guide
-
1 credit
TikTok Video API
Plays, likes, comments, shares and saves of one TikTok video, with its caption, hashtags, sound and creator.
GET /v1/tiktok/video -
1 credit / 20
TikTok Comments API
The top comments of a TikTok video with likes, reply counts, dates, creator-liked flags and the commenters' usernames.
GET /v1/tiktok/comments
More TikTok guides
- How to get a TikTok video's views and likes in Python
- How to get a TikTok follower count in Python
- TikTok Research API: who can get access, and what to do if you cannot
- How to get TikTok video views, likes and shares in Node.js
- How to get TikTok views, likes and follower counts in Google Sheets
Guides for other sources
Every source
YouTube
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube transcripts and video stats in Google Sheets
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to get a YouTube channel's subscriber count in Python
- How to give Claude or Cursor access to YouTube (MCP server)
- How to get YouTube comments in Node.js
- How to analyze YouTube comments with an LLM in Python
- How to list a YouTube channel's Shorts in Python
- How to search YouTube from JavaScript
- How to get an Instagram follower count in Python
- Instagram Basic Display API alternatives: what to use after the shutdown
- Instaloader 401 Unauthorized, 429 and "Login required": what to do
- How to calculate an Instagram engagement rate in Python
- How to get an Instagram follower count in Node.js
- How to get Instagram follower counts in Google Sheets
- How to get Instagram Reel views in Python
Websites
- Clearbit Logo API alternatives: get a company logo from its domain
- How to extract email addresses from a website in Python
- How to turn a web page into Markdown in Python
- How to detect what a website is built with, in Python
- How to get the contact emails and phone numbers of websites in Google Sheets
- How to build a LangChain tool that reads web pages and searches Google
- How to turn a web page into Markdown in JavaScript for RAG
- How to extract social media links from a website in Python
- How to get a website's favicon in Python
- How to check robots.txt in Python before you fetch a page
- How to get a Facebook Page's posts without app review
- Is there a Facebook Marketplace API?
- Facebook Groups API alternatives after its removal in 2024
- How to get a Facebook Page's follower count and contact details in Python
- How to get Google search results in Python
- pytrends 429 TooManyRequestsError: what it means and what to do
- How to get Google Trends data in Python
- Why is Wyoming first in Google Trends?
- How to get Google search results in Node.js
- How to get Google search results into Google Sheets
- How to give an LLM live Google results with tool calling
Threads
- How to get LinkedIn company data in Python
- How to search LinkedIn jobs from Python
- How to get a LinkedIn company page's latest posts in Python