All posts

How to Scrape TikTok Data: Official APIs, Python and CSV

November 9, 2026

Short answer

To scrape TikTok data, first check whose accounts you need: TikTok's Display API reads only users who log in to your app, and its Research API is limited to approved non-commercial researchers. For other public profiles and videos you can run an open-source Python tool such as yt-dlp, or call a hosted API that returns JSON, then write the rows to CSV.

Scraping TikTok means turning public profiles, videos and comments into rows you can sort and count. There are three routes: TikTok's official APIs, open-source tools you run yourself, and a hosted API. The right one depends on whose accounts you need to read and how often. Each route below comes with code, and the last part shows a CSV export that opens cleanly in Excel. To compare vendors instead, see best TikTok scrapers and APIs.

What TikTok data is public

ObjectWhat anyone can seeWhat only the creator sees
ProfileHandle, display name, bio, avatar, followers, following, total likes, video count, verified badgeFollower demographics, profile view history
VideoCaption, hashtags, post time, views, likes, comments, shares, saves, duration, soundWatch time, completion rate, traffic sources
CommentText, time, likes, reply count, author handleComments the creator filtered or deleted
SoundTitle, author, duration, videos using itNone
Search and hashtagsVideos that match a keyword or tagHow the For You feed ranks them for a given person

Private accounts are off limits on every route. If a field sits in the right-hand column, no scraper can get it; only the creator can, through TikTok's own analytics.

Route 1: the official TikTok APIs

APIWho can use itWhat it readsLimits
Display APIAny registered developer appProfile and public videos of users who log in to your app600 requests a minute per endpoint
Research APIApproved researchers; creators, advertisers and commercial users are not eligiblePublic videos, comments, users, follower lists1,000 requests and 100,000 records a day, 100 records per request

With the Display API, the user.info.stats scope returns follower_count, following_count, likes_count and video_count (user info docs), and each video object carries view_count, like_count, comment_count, share_count and a Unix create_time (video object). Limits are in TikTok's rate limit page. It fits apps where creators connect their own accounts, not research on accounts you don't control.

The Research API is richer but slow to catch up. TikTok's Research API FAQ says new videos can take up to 48 hours to become searchable and that statistics such as views and follower counts can take up to 10 days to update. It works for studies, not for live dashboards. More detail is in Is the TikTok API free?

Route 2: a TikTok scraper in Python

yt-dlp is the best-maintained free tool that reads TikTok. Its latest release on 9 November 2026 was 2026.10.26. Its supported sites list shows which TikTok pages work today:

yt-dlp extractorStatus on 9 November 2026
TikTok (one video), tiktok:user, tiktok:collection, tiktok:liveListed as working
tiktok:tag, tiktok:sound, tiktok:effectMarked "Currently broken"

This script reads a profile's latest 30 videos without downloading any media:

from yt_dlp import YoutubeDL

opts = {"skip_download": True, "quiet": True, "playlistend": 30, "ignoreerrors": True}
with YoutubeDL(opts) as ydl:
    info = ydl.extract_info("https://www.tiktok.com/@nasa", download=False)

rows = []
for v in info.get("entries") or []:
    if not v:
        continue
    rows.append({
        "id": v.get("id"),
        "url": v.get("webpage_url"),
        "posted": v.get("timestamp"),
        "caption": v.get("description") or v.get("title"),
        "views": v.get("view_count"),
        "likes": v.get("like_count"),
        "comments": v.get("comment_count"),
        "shares": v.get("repost_count"),
        "saves": v.get("save_count"),
        "duration": v.get("duration"),
    })

Watch the names. yt-dlp's TikTok extractor maps TikTok's playCount to view_count, shareCount to repost_count and collectCount to save_count. A share is not a repost on TikTok, so rename the column before anyone reads your sheet.

The other common library is TikTok-Api (MIT, about 6,700 stars, last push 24 August 2026). It needs Python 3.9 or newer, a Playwright browser and an ms_token taken from your own tiktok.com cookies. Its README says an EmptyResponseException means TikTok detected a bot and blocked the request. This guide does not cover ways around that. If a free tool stops working, slow down or switch routes.

Both tools break when TikTok changes its pages, run from your own IP address, and leave fixes to you. They suit a one-off pull of a few profiles from a laptop.

Route 3: a hosted TikTok API

A hosted API returns JSON over HTTP, so there is no browser to run and no session to keep alive. Here is the same 30-video pull with ScrapeIO, paging with the cursor each answer returns:

import requests

KEY = "YOUR_KEY"

def get(path, **params):
    r = requests.get("https://scrapeio.com" + path, params=params,
                     headers={"x-api-key": KEY}, timeout=60)
    body = r.json()
    return body["data"] if body.get("success") else None

def videos(handle, pages=3):
    cursor = None
    for _ in range(pages):
        page = get("/v3/tiktok/profile/videos", handle=handle, cursor=cursor)
        if not page:
            return
        yield from page["items"]
        if not page["has_more"]:
            return
        cursor = page["cursor"]

profile = get("/v1/tiktok/profile", handle="nasa")
rows = list(videos("nasa"))

Each video comes back with plays, likes, comments, shares, saves and created_at, the same field names used for Instagram and YouTube.

Export TikTok data to CSV

A CSV that opens cleanly in Excel needs four things: UTF-8 with a byte order mark so emoji in captions survive, ids stored as text, readable dates, and a column that says when you pulled the row.

import csv, datetime

pulled = datetime.datetime.now(datetime.timezone.utc).isoformat()
cols = ["id", "url", "created_at", "caption", "plays", "likes", "comments", "shares", "saves", "pulled_at"]

with open("tiktok_videos.csv", "w", newline="", encoding="utf-8-sig") as f:
    w = csv.DictWriter(f, fieldnames=cols, extrasaction="ignore")
    w.writeheader()
    for v in rows:
        w.writerow({**v, "id": "'" + str(v["id"]), "pulled_at": pulled})

The leading apostrophe stops Excel from turning a 19-digit video id into scientific notation. Drop it if the file goes into a database instead. For yt-dlp rows, convert posted from Unix seconds with datetime.datetime.fromtimestamp(ts, datetime.timezone.utc). To export a follower list instead of videos, see how to export a TikTok followers list.

The three routes side by side

Official APIsyt-dlp or TikTok-ApiHosted API
Money costNone listedNonePer call
Accounts you can readYour app's users (Display) or research samplesPublic accountsPublic accounts
Comments and searchResearch API onlyPartial; tag and sound pages broken in yt-dlpYes
FreshnessLive (Display), up to 10 days behind (Research)LiveLive or cached
UpkeepToken refresh, app reviewYou fix breakagesThe vendor's job

What a typical project costs

Say you audit 50 creators: one profile call, three pages of videos and comments on each creator's top 5 videos. That is 50 x (1 + 3 + 5) = 450 calls. At ScrapeIO's Starter rate of $1.88 per 1,000 credits, it costs about $0.85, and calls that fail or find a private account are not charged. The same audit with yt-dlp costs nothing in money but leaves out comments, and takes as long as TikTok lets it.

Terms and the legal side

TikTok's US terms of service (section 3.4) forbid using automated systems to "scrape, crawl, export or otherwise extract any data or content in any form, for any purpose" without written approval. Courts have treated terms differently from hacking laws, and the facts matter: logged in or not, public or private, what you do with the data. Collect public data only, keep the minimum, and do not build profiles of private people.

This is not legal advice. Terms and law change, and the answer depends on where you are and what you do with the data. Our guide to the main web scraping cases has the background.

Doing it with ScrapeIO

ScrapeIO's TikTok profile API, profile videos API, comments API and keyword search API each cost 1 credit a call and need no TikTok account. All TikTok endpoints are on the TikTok platform page, and AI agents can call them through the TikTok MCP server.

FAQ

Can you scrape TikTok without an account?

Yes, for public data. yt-dlp reads public profile and video pages without logging in, and a hosted API needs only its own key. TikTok-Api needs an ms_token from your browser cookies.

Does TikTok have a free API for scraping?

TikTok lists no fee, but the Display API only reads users who authorize your app, and the Research API is for approved researchers. Neither is a general scraping API.

Is it legal to scrape TikTok?

TikTok's terms forbid automated collection without its approval, and the legal answer depends on your country and use. Stick to public data and get legal advice for commercial projects.

How do I export TikTok data to Excel?

Write a CSV with UTF-8 and a byte order mark (utf-8-sig in Python), keep ids as text, and open it in Excel. The script above does all three.

Can I scrape TikTok comments?

Yes, for public videos. The Research API includes comments for approved researchers, and hosted APIs return them by video URL. See our TikTok comment scraper guide.

Sources

Checked on 9 November 2026 from each vendor's own pages. Prices and limits change; follow the links before you decide.

100 free credits, no card. Credits never expire.

Get API key