How to scrape TikTok comments with an API
To scrape TikTok comments, send a public video URL to one endpoint and pass nextCursor back until hasMore is false. This guide shows the request, a real response and what to do on errors.
1. Send the request
Create a free account (100 credits, no card), copy the key from the dashboard and export it as CAPTAPI_KEY. The only required parameter is url, the link of a public TikTok video.
Get five comments from one video
curl -G "https://api.captapi.com/v1/tiktok/comments" \
--data-urlencode "url=https://www.tiktok.com/@khaby.lame/video/7646812028874673439" \
--data-urlencode "limit=5" \
-H "Authorization: Bearer $CAPTAPI_KEY"2. Read the response
This is a real response from 22 November 2026, read from the 24-hour cache at 0 credits and trimmed to two of its five comments. We masked user names and ids and left out avatar URLs and authorSecUid.
200 OK
{
"success": true,
"data": {
"platform": "tiktok",
"url": "https://www.tiktok.com/@khaby.lame/video/7646812028874673439",
"totalComments": 1711,
"totalReturned": 5,
"comments": [
{
"id": "<comment-id-1>",
"text": "1 like = 1 pushups",
"author": "<username-1>",
"authorName": "<display-name-1>",
"authorId": "<user-id-1>",
"commentLanguage": "en",
"likeCount": 751,
"publishedAt": "2026-06-08T09:47:20.000Z"
},
{
"id": "<comment-id-2>",
"text": "Mr beast 500 million 🥰🇧🇩",
"author": "<username-2>",
"authorName": "<display-name-2>",
"authorId": "<user-id-2>",
"commentLanguage": "en",
"likeCount": 303,
"publishedAt": "2026-06-02T16:23:41.000Z"
}
],
"nextCursor": "5",
"hasMore": true,
"fetchedAt": "2026-11-22T14:48:12.380Z"
}
}- author is the handle and authorName is the display name. authorId stays the same when a user changes handle.
- commentLanguage is the language code TikTok reports. It can be wrong or missing on short comments.
- totalComments is the total TikTok reports for this comment list. It changes between reads and can differ from the count shown on the video.
3. Page through the comments
nextCursor is a numeric offset sent as a string. Pass it back as cursor with the same url and limit, and stop when hasMore is false.
TikTok reorders comments between reads, so an offset can land on a comment you already have. Keep a set of ids and cap the number of pages, because each page that returns comments is a 2-credit call.
Collect unique comments with a page cap
import os
import time
import requests
API = "https://api.captapi.com/v1/tiktok/comments"
HEADERS = {"Authorization": f"Bearer {os.environ['CAPTAPI_KEY']}"}
def get_page(params, attempts=4):
for attempt in range(1, attempts + 1):
res = requests.get(API, params=params, headers=HEADERS, timeout=150)
body = res.json()
if res.ok:
return body["data"]
error = body["error"]
if not error["retryable"] or attempt == attempts:
raise RuntimeError(f"{res.status_code} {error['code']}: {error['message']}")
time.sleep(int(res.headers.get("Retry-After", "30")))
def scrape_comments(url, limit=100, max_pages=5):
params = {"url": url, "limit": limit}
seen = {}
for _ in range(max_pages):
data = get_page(params)
for comment in data["comments"]:
seen[comment["id"]] = comment
if not data.get("hasMore"):
break
params["cursor"] = data["nextCursor"]
return list(seen.values())
comments = scrape_comments("https://www.tiktok.com/@khaby.lame/video/7646812028874673439")
print(len(comments), "unique comments")Choose the parameters
| Parameter | Default | When to change it |
|---|---|---|
| url | required | The video link. A profile link or a link from another platform is refused. |
| limit | 50 | Raise it to 500 to spend fewer calls. The price per call stays 2 credits. |
| cursor | none | Leave it out for the first page, then send the last nextCursor. |
| cache | false | Set true when a result up to 24 hours old is good enough; a cache hit costs 0 credits. |
Export TikTok comments to CSV
For a spreadsheet or a labelling job, write only the columns you need. This example keeps the language, time, like count and text and leaves out who wrote each comment. Filter on commentLanguage afterwards to review one market at a time. A spreadsheet can run a cell that starts with =, +, - or @ as a formula, so the script puts an apostrophe in front of those.
Write one call to comments.csv
import csv
import os
import time
import requests
API = "https://api.captapi.com/v1/tiktok/comments"
HEADERS = {"Authorization": f"Bearer {os.environ['CAPTAPI_KEY']}"}
def get_page(params, attempts=4):
for attempt in range(1, attempts + 1):
res = requests.get(API, params=params, headers=HEADERS, timeout=150)
body = res.json()
if res.ok:
return body["data"]
error = body["error"]
if not error["retryable"] or attempt == attempts:
raise RuntimeError(f"{res.status_code} {error['code']}: {error['message']}")
time.sleep(int(res.headers.get("Retry-After", "30")))
data = get_page({"url": "https://www.tiktok.com/@khaby.lame/video/7646812028874673439", "limit": 500})
with open("comments.csv", "w", newline="", encoding="utf-8") as file:
out = csv.writer(file)
out.writerow(["publishedAt", "commentLanguage", "likeCount", "text"])
for comment in data["comments"]:
text = comment["text"]
if text.startswith(("=", "+", "-", "@")):
text = "'" + text
out.writerow([comment.get("publishedAt"), comment.get("commentLanguage"), comment.get("likeCount"), text])4. Handle errors and retryable
Every error has the same body: success is false and error holds code, message and retryable. Retry only when retryable is true, wait for the Retry-After header, and cap the attempts. Failed requests cost 0 credits.
| Status | error.code | retryable | What to do |
|---|---|---|---|
| 400 | WRONG_RESOURCE_TYPE or BAD_REQUEST | false | Send a video URL, and only a cursor that came from nextCursor. |
| 401 | UNAUTHORIZED | false | Check the API key. |
| 402 | insufficient_credits | false | You need at least 2 credits for the call. |
| 404 | NOT_FOUND | false | The video does not exist or is not public. |
| 422 | VALIDATION_ERROR | false | Keep limit between 1 and 500. |
| 429 | rate_limit_exceeded | true | You passed your plan's per-minute limit. Wait for Retry-After. |
| 503 | UPSTREAM_UNAVAILABLE | true | TikTok did not return the comments. Retry the same cursor after Retry-After. |
Limits and cost
- limit goes up to 500, and a call can return fewer.
- Five pages of 100 comments cost 10 credits. A page with no comments costs 0.
- cache=true can return a response up to 24 hours old for 0 credits. Don't mix cached and fresh pages when order matters.
- Replies are a separate endpoint: pass the comment id to /v1/tiktok/comment-replies.
- Only public videos are covered. Private and deleted videos are not.
Responsible use
Captapi returns publicly available data only. You are responsible for how you use it and for complying with applicable laws and each platform's terms.
Comments are personal data in many countries, and some authors are minors. Keep only the fields you need, set a deletion date, honour deletion requests, and don't use the data to profile, contact or harass the people who wrote them.
Sources: TikTok Terms of Service (US)
Frequently asked questions
Can I scrape TikTok comments with Python?
Yes. Send a GET request with the requests library to /v1/tiktok/comments with the video URL and your Captapi key. The comments are in data.comments.
How do I get more than one page of TikTok comments?
Pass nextCursor back as cursor until hasMore is false, and de-duplicate by comment id.
Why is totalComments different from the count on the video?
It is the total TikTok reports for the comment list, and it moves between reads. For the count shown on the video, read engagement.comments from /v1/tiktok/video-details.
Can I export TikTok comments to CSV?
The API returns JSON. Write data.comments to a file with Python's csv module, picking the columns you need.
How much does it cost to scrape 1,000 TikTok comments?
4 credits when two calls with limit=500 both return full pages. When TikTok returns shorter pages it takes more calls, at 2 credits each.
Plans and credit packs are on the pricing page. Every parameter and field is on the TikTok Comments API page.