# 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.

[![apidojo](/blog/authors/apidojo.png)**Apidojo** *15+ years of experience in data retrieval.*](/blog/authors/apidojo/)

**12 October 2026** Published

**4 min** Read

![Cover card reading 'How to Build a TikTok Dataset for AI and Research'](/blog/covers/ai-research-dataset.png)

**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](/blog/tiktok-scraping/how-to-scrape-tiktok/). This guide extends the recurring pattern in [how to monitor TikTok trends with an API](/blog/tiktok-scraping/monitor-trends/). The collection steps are the same ones used to [find TikTok influencers by niche with data](/blog/tiktok-scraping/find-influencers/) and to [track competitors on TikTok](/blog/tiktok-scraping/track-competitors/).

## 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](https://apify.com/apidojo/tiktok-scraper), [Apify](https://apify.com/apidojo/tiktok-comments-scraper)).

| 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](https://apify.com/apidojo/tiktok-scraper/input-schema)).

```
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](/blog/tiktok-scraping/scrape-comments/), and analysing them in [how to analyse TikTok comment sentiment](/blog/tiktok-scraping/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](/blog/tiktok-api/research-api/).

## 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.

## The scrapers behind this

-   [TikTok Scraper Profiles, videos, hashtags, music and locations; 460 posts/sec measured $0.30 / 1K posts](/scrapers/tiktok-scraper/)
-   [TikTok Comments Scraper Comments, likes and replies from video URLs; 100–200 comments/sec $0.30 / 1K comments](/scrapers/tiktok-comments-scraper/)

## 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](/blog/tiktok-scraping/tiktok-python/).

## More on monitoring TikTok with data

-   [How to Monitor TikTok Trends With an API Build a TikTok trend monitor for hashtags, sounds and keywords: Python code, the growth signals that matter, alerts and costs.](/blog/tiktok-scraping/monitor-trends/)
-   [How to Find TikTok Influencers by Niche With Data Build an influencer shortlist from niche content, filter by tier, score creators on median views and engagement, and spot red flags.](/blog/tiktok-scraping/find-influencers/)
-   [How to Track Competitors on TikTok Track rival TikTok accounts weekly: posting volume, median views, engagement, top posts, formats and follower growth, with Python.](/blog/tiktok-scraping/track-competitors/)
-   [How to Analyse TikTok Comment Sentiment Export TikTok comments, split them by language, score sentiment with VADER, weight by likes and find what people talk about.](/blog/tiktok-scraping/comment-sentiment/)

![apidojo](/blog/authors/apidojo.png)

## [Apidojo](/blog/authors/apidojo/)

15+ years of experience in data retrieval.

API Dojo is always ready for you. With 15+ years of experience, data acquisition has never been that easy. Cheapest prices with high availability.

-   🏯 15+ years of experience in data retrieval.
-   💰 Cheapest prices, qualified data.
-   ⚙️ High availability, extreme maintenance.
-   🐉 Hyper communicative, excellent support.

-   [apify.com](https://apify.com/apidojo)
-   [x.com](https://x.com/apidojo_)
-   [github.com](https://github.com/apidojo-io)
