TikTok Comments API with Python: Fetch, Paginate and Analyze Video Comments
A practical Python walkthrough: pull TikTok video comments through a normalized JSON API, paginate with sealed cursors, and hand clean records to your analysis pipeline.
Last reviewed
Quickstart
Every request needs one header: Authorization: Bearer $FETCHPI_API_KEY. Create a free key in the console and you can replay every snippet on this page as-is.
curl -s -H "Authorization: Bearer $FETCHPI_API_KEY" "https://fetchpi.com/v1/tiktok/posts/{id}/comments?freshness=default"Why normalized comments matter
Comment scraping breaks on every layout change and gives you a different JSON shape per platform. FetchPI returns comments as one record type — author, text, created_at, metrics — whether the video is TikTok, a Reddit post or a YouTube video. Your analysis code stays platform-agnostic.
Fetch and paginate
Lists return a sealed opaque cursor in next_cursor. Pass it back as cursor — a cursor issued by another provider is rejected rather than silently misread.
import os, requests
API = "https://fetchpi.com"
KEY = os.environ["FETCHPI_API_KEY"]
def comments(post_id, cursor=None):
params = {"freshness": "default"}
if cursor:
params["cursor"] = cursor
r = requests.get(
f"{API}/v1/tiktok/posts/{post_id}/comments",
headers={"Authorization": f"Bearer {KEY}"},
params=params, timeout=30,
)
r.raise_for_status()
return r.json()
page = comments("7410886000000000001")
for c in page["data"]:
print(c["author"]["username"], c["text"][:60])
while page.get("next_cursor"):
page = comments("7410886000000000001", page["next_cursor"])What a normalized comment looks like
{
"id": "7410886123456789012",
"platform": "tiktok",
"type": "comment",
"author": {"id": "7004994945113", "username": "creator.dev", "verified": true},
"text": "This is the way.",
"created_at": "2026-10-01T10:00:00Z",
"metrics": {"likes": 864},
"fetched_at": "2026-10-19T09:00:00Z"
}Cost control
Comments pages are billed per successful call. For periodic re-reads of the same video use freshness=default with a max_age you can tolerate — cache-mode hits bill at the catalog cache tier (most capabilities half price), and meta.billing in every response shows what you actually paid.