How to Build a TikTok Dataset for AI and Research

To build a TikTok dataset for AI or research, collect public videos for your topic with apidojo's TikTok Scraper on Apify, add the comments on the videos that matter with the Comments Scraper, and save each record as one line of JSON with its text, date, engagement, creator and link.

Cover card reading 'How to Build a TikTok Dataset for AI and Research'

To build a TikTok dataset for AI or research, collect public videos for your topic with apidojo’s TikTok Scraper on Apify, add the comments on the videos that matter with the Comments Scraper, and save each record as one line of JSON with its text, date, engagement, creator and link. TikTok Scraper’s output also includes subtitle file links, when a video has captions, which give you the spoken words as text.

Video platforms are hard to study as text, so the useful layers are captions, subtitles, hashtags and comments. This guide covers what to collect, how to structure it, and what academic researchers can use instead. The full scraping overview is in how to scrape TikTok data in 2026. This guide extends the recurring pattern in how to monitor TikTok trends with an API. The collection steps are the same ones used to find TikTok influencers by niche with data and to track competitors on TikTok.

What TikTok Data Is Useful for AI and Research?

4 layers of TikTok data carry most of the signal: captions, subtitles, comments and engagement. The table maps each to the apidojo output field that holds it (Apify, Apify).

Layer Field Actor
Caption text title, hashtags TikTok Scraper
Spoken words subtitleInformation (subtitle file links, when available) TikTok Scraper
Audience reaction text, likeCount, commentLanguage TikTok Comments Scraper
Engagement views, likes, comments, shares, bookmarks TikTok Scraper
Context uploadedAtFormatted, channel, song, postPage TikTok Scraper

How Do You Collect the Videos?

Search your topic with keywords, or collect hashtag and profile URLs, and set a country with location if the study is regional. For keyword searches, the dateRange input limits results to a period such as LAST_SIX_MONTHS (Apify).

import json
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("apidojo/tiktok-scraper").call(run_input={
    "keywords": ["climate anxiety"],
    "dateRange": "LAST_SIX_MONTHS",
    "includeSearchKeywords": True,
    "maxItems": 2000,
})

with open("videos.jsonl", "w", encoding="utf-8") as f:
    for v in client.dataset(run.default_dataset_id).iterate_items():
        f.write(json.dumps({
            "id": v["id"], "url": v["postPage"], "created": v["uploadedAtFormatted"],
            "creator": v["channel"]["username"], "caption": v["title"],
            "hashtags": v["hashtags"], "views": v["views"], "likes": v["likes"],
            "subtitles": [s["url"] for s in (v.get("subtitleInformation") or [])],
        }, ensure_ascii=False) + "\n")

It costs $0.30 per 1,000 posts, and each query must return at least 10 posts (Apify).

How Do You Get What Videos Say?

Each entry in subtitleInformation points to a subtitle file, in the WebVTT format in apidojo’s example, with its language code; download the file to get the spoken words with timestamps. Not every video has captions, and the example includes an expiry value, so download the files soon after the run (Apify). Videos without subtitles still carry their caption text and hashtags.

How Do You Add Comments to the Dataset?

Pass the postPage links of the videos you want into the TikTok Comments Scraper, and store comments in a separate file linked by the video ID. Each comment’s awemeId field holds the ID of the video it was posted on, which joins the two files (Apify). The method is in how to scrape TikTok comments and replies, and analysing them in how to analyse TikTok comment sentiment.

How Should You Structure the Dataset?

Keep one JSON Lines file per record type, videos and comments, with IDs that link them, and keep the URL with every record so findings can be traced back. Remove duplicate IDs, because a video can match several keywords. Replace usernames with placeholders if you publish results, to protect the people in the data.

What Can Academic Researchers Use Instead?

Researchers at eligible non-profit academic institutions can apply for TikTok’s Research API, which covers public videos, comments, accounts and follower lists within daily quotas. Approval takes an application and a research proposal. The details are in TikTok Research API: eligibility, access and limits.

What Rules Apply to TikTok Data for AI?

TikTok content contains personal data and is subject to TikTok’s terms and to laws such as the GDPR, so check both before collecting, and especially before training a model on it. Collect only what your project needs, store it securely, and keep creators’ videos inside your research rather than republishing them.

Questions people ask

How big should a TikTok research dataset be?

It depends on the question; thousands of videos suit topic studies, while trend studies need data across several periods.

Can you get TikTok transcripts without subtitles?

If a video has no subtitle file, you'd need speech-to-text on audio you have the right to process.

Can you collect TikTok data by country?

Yes, set location to an ISO country code.

Where do you start?

At how to collect TikTok data with Python.