# Tiktok Scraper (`mcdowell/tiktok`) Actor

An advanced TikTok scraper that lets you collect  videos, profiles, posts, and other publicly available data on TikTok. Download TikTok data as a HTML, JSON, CSV, Excel, or XML

- **URL**: https://apify.com/mcdowell/tiktok.md
- **Developed by:** [McDowell](https://apify.com/mcdowell) (community)
- **Categories:** Videos, Social media
- **Features:** Limited permissions
- **Stats:** 940 total users, 6 monthly users, 100.0% runs succeeded, 19 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $10.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## What is TikTok Scraper

This Scraper crawls [Tiktok](https://tiktok.com) and extracts information on the videos hosted on the website.
The video information is very detailed and can be exported to the following formats **CSV**,**EXCEL**,**HTML**, **JSON**,**XML**

### Features

Scraper allows you to scrape:

- **Individual Video Posts** - by using a specific video URL.
- **Account** - Results from individual [Tiktok](https://tiktok.com) account names.
- **Hashtag** - Videos that contain a specific hashtag.

#### Sample Input

```json
{
	"maxCommentsPerPost": 20,
	"maxVideosPerPage": 20,
	"proxyConfig": {
	    "useApifyProxy": true
	},
	"profiles": [
	    "khaby.lame"
	],
	"hashtags": [
	    "tiktokshortfilm"
	]
}
```

### Output

The output can be be set to contain or ignore comments to the videos.

#### Comments

The default output has been set to a maximum of **20 videos** and **20 comments**.
Changing the number of maximum comments in the Input allows for increase/decrease the number of comments per video.

#### Sample output;

```json
{
  "id": "7167271500058234139",
  "desc": "Apa?? Ternyata pacarku kelly…😱@Kelly 🍒 #drama #dramatiktok #tiktokviral #tiktokshortfilm #romantis #romance #fyptiktok #anhong @Anhong Media International ",
  "createTime": 1668760442,
  "duetInfo": {
    "duetFromId": "0"
  },
  "commentCount": 11400,
  "diggCount": 3600000,
  "playCount": 53200000,
  "shareCount": 12900,
  "originCover": "https://p16-sign-va.tiktokcdn.com/obj/tos-useast2a-p-0037-aiso/0ec5a3c9ecee4252a8927756e8ed51fd_1668760536?x-expires=1674644400&x-signature=CAoZ29sxfOTVVxJFyCB85ULqaTM%3D",
  "streamVideoUrl": "https://v16-webapp-prime.us.tiktok.com/video/tos/useast2a/tos-useast2a-pve-0037-aiso/oIxKzhoWIKxQGvBsUA30dnfWAuUF2hN6PoAzFs/?a=1988&ch=0&cr=0&dr=0&lr=tiktok&cd=0%7C0%7C1%7C0&cv=1&br=2554&bt=1277&cs=0&ds=3&ft=4KJMyMzm8Zmo0aasI64jVJhrdpWrKsdm&mime_type=video_mp4&qs=0&rc=PDY0aTY8NDplN2Q5NGllM0BpM3dyM2k6ZnBuZzMzZjgzM0AzMzZfY2E1NS4xYl8uMWJiYSNeYC8ycjQwMm9gLS1kL2Nzcw%3D%3D&expire=1674645146&l=202301250510008F7B77C1CFC2DD10507B&policy=2&signature=52d71b82952a38650f479efd76a53b9c&tk=tt_chain_token",
  "videoUrl": "https://www.tiktok.com/@mrdanielwille/video/7167271500058234139",
  "downloadAddress": "https://v16-webapp-prime.us.tiktok.com/video/tos/useast2a/tos-useast2a-pve-0037-aiso/oIxKzhoWIKxQGvBsUA30dnfWAuUF2hN6PoAzFs/?a=1988&ch=0&cr=0&dr=0&lr=tiktok&cd=0%7C0%7C1%7C0&cv=1&br=2554&bt=1277&cs=0&ds=3&ft=4KJMyMzm8Zmo0aasI64jVJhrdpWrKsdm&mime_type=video_mp4&qs=0&rc=PDY0aTY8NDplN2Q5NGllM0BpM3dyM2k6ZnBuZzMzZjgzM0AzMzZfY2E1NS4xYl8uMWJiYSNeYC8ycjQwMm9gLS1kL2Nzcw%3D%3D&expire=1674645146&l=202301250510008F7B77C1CFC2DD10507B&policy=2&signature=52d71b82952a38650f479efd76a53b9c&tk=tt_chain_token",
  "subtitleInfos": [
    {
      "Format": "webvtt",
      "LanguageCodeName": "ind-ID",
      "LanguageID": "23",
      "Size": 2916,
      "Source": "ASR",
      "Url": "https://v16m-webapp.tiktokcdn-us.com/a9ba3accff466fb8a4d944bc469c7d96/63d10e9a/video/tos/useast2a/tos-useast2a-pv-0037-aiso/d60dcf7113054125887c8b9c89caa1c8/?a=1988&ch=0&cr=0&dr=0&lr=tiktok&cd=0%7C0%7C1%7C0&cv=1&br=20216&bt=10108&cs=0&ds=4&ft=4KLMeMzm8Zmo0aasI64jVJhrdpWrKsdm&mime_type=video_mp4&qs=13&rc=M3dyM2k6ZnBuZzMzZjgzM0BpM3dyM2k6ZnBuZzMzZjgzM0BeYC8ycjQwMm9gLS1kL2NzYSNeYC8ycjQwMm9gLS1kL2Nzcw%3D%3D&l=202301250510008F7B77C1CFC2DD10507B",
      "UrlExpire": 1674645146,
      "Version": "1",
      "VideoSubtitleID": 1315104337
    }
  ],
  "format": "mp4",
  "shareCover": [
    "",
    "https://p16-sign-va.tiktokcdn.com/tos-useast2a-p-0037-aiso/0ec5a3c9ecee4252a8927756e8ed51fd_1668760536~tplv-tiktok-play.jpeg?x-expires=1675227600&x-signature=NYwd8Vs7bJ3Lhj6hXalHdA8TQ9U%3D",
    "https://p16-sign-va.tiktokcdn.com/tos-useast2a-p-0037-aiso/0ec5a3c9ecee4252a8927756e8ed51fd_1668760536~tplv-tiktokx-share-play.jpeg?x-expires=1675227600&x-signature=%2F7904J0FVZ994cbFCSwA1Sbfmrk%3D"
  ],
  "authorInfo": {
    "avatarLarger": "https://p16-sign-va.tiktokcdn.com/tos-useast2a-avt-0068-giso/3577672cbac84a1508af092fcfa36922~c5_1080x1080.jpeg?x-expires=1674795600&x-signature=MduKVqV%2FbBevOY%2BcZvBHTTs74WU%3D",
    "avatarMedium": "https://p16-sign-va.tiktokcdn.com/tos-useast2a-avt-0068-giso/3577672cbac84a1508af092fcfa36922~c5_720x720.jpeg?x-expires=1674795600&x-signature=oieGs9%2BWFW4wmtKdFywzp5qrLHY%3D",
    "avatarThumb": "https://p16-sign-va.tiktokcdn.com/tos-useast2a-avt-0068-giso/3577672cbac84a1508af092fcfa36922~c5_100x100.jpeg?x-expires=1674795600&x-signature=rnzcrz6Khvkyq6MVXSAOAhxEoSc%3D",
    "commentSetting": 0,
    "downloadSetting": 0,
    "duetSetting": 0,
    "ftc": false,
    "id": "7079634028320179227",
    "isADVirtual": false,
    "isEmbedBanned": false,
    "nickname": "mrdanielwille",
    "openFavorite": false,
    "privateAccount": false,
    "relation": 0,
    "secUid": "MS4wLjABAAAARaGT-NJ_7ETosv8GdNB_lohxK-O7evzvfPxLm-Mi12hhk_uicQW1bVA6xynLvaEj",
    "secret": false,
    "signature": "Di-follow ya akun IG kita🤗\nDM for business inquiries",
    "stitchSetting": 0,
    "ttSeller": false,
    "uniqueId": "mrdanielwille",
    "verified": false,
    "diggCount": 756,
    "followerCount": 2100000,
    "followingCount": 15,
    "heart": 53400000,
    "heartCount": 53400000,
    "videoCount": 217
  },
  "musicInfo": {
    "album": "Dino Song",
    "authorName": "Mr. Popolo",
    "coverLarge": "https://p16-sg.tiktokcdn.com/aweme/720x720/tos-alisg-v-2774/f14e4f0561c14962b7686f0f8d928cc5.jpeg",
    "coverMedium": "https://p16-sg.tiktokcdn.com/aweme/200x200/tos-alisg-v-2774/f14e4f0561c14962b7686f0f8d928cc5.jpeg",
    "coverThumb": "https://p16-sg.tiktokcdn.com/aweme/100x100/tos-alisg-v-2774/f14e4f0561c14962b7686f0f8d928cc5.jpeg",
    "duration": 31,
    "id": "7036910067001591810",
    "original": false,
    "playUrl": "https://sf16-ies-music-sg.tiktokcdn.com/obj/tos-alisg-ve-2774/oYBRUbPcQDWDxxjBX6jtSniBioeRQPYbgCEeUZ",
    "title": "Dino Song"
  },
  "isAd": false,
  "adAuthorization": false,
  "adLabelVersion": 0,
  "hashtags": [
    {
      "hashtagId": "5673",
      "hashtagName": "drama"
    },
    {
      "hashtagId": "1589208482678785",
      "hashtagName": "dramatiktok"
    },
    {
      "hashtagId": "86427221",
      "hashtagName": "tiktokviral"
    },
    {
      "hashtagId": "1614906296858629",
      "hashtagName": "tiktokshortfilm"
    },
    {
      "hashtagId": "14081669",
      "hashtagName": "romantis"
    },
    {
      "hashtagId": "57155",
      "hashtagName": "romance"
    },
    {
      "hashtagId": "1630284807035909",
      "hashtagName": "fyptiktok"
    },
    {
      "hashtagId": "67447817",
      "hashtagName": "anhong"
    }
  ],
  "challenges": [
    {
      "id": "5673",
      "title": "drama",
      "desc": "",
      "profileThumb": "",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    },
    {
      "id": "1589208482678785",
      "title": "dramatiktok",
      "desc": "",
      "profileThumb": "",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    },
    {
      "id": "86427221",
      "title": "tiktokviral",
      "desc": "",
      "profileThumb": "",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    },
    {
      "id": "1614906296858629",
      "title": "tiktokshortfilm",
      "desc": "To celebrate our partnership with Cannes International Film Festival, we invite you to join our global #TikTokShortFilm competition. \n\nFrom March 15th to April 8th, create and submit your scripted vertical short film (from 30 seconds to 3 minutes) for a chance to win a trip to Cannes International Film Festival and a cash prize up to 10.000 Euros. The 3 finalists, selected amongst 3 awards by renowned judges, will also have the chance to travel to Cannes to receive their prize during our TikTok Awards Ceremony, and attend exclusive screenings during the Festival. No matter your budget or your experience, we want to see your talent and creativity. \n\nTo enter the competition and submit your video, please make sure to follow all the necessary steps, consult Terms &amp; Conditions and Video Requirements here: https://zjsms.com/NBj9YLj/",
      "profileThumb": "https://p16-amd-va.tiktokcdn.com/obj/musically-maliva-obj/25350af495e36baa1bdf5d5865902bbf.png",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    },
    {
      "id": "14081669",
      "title": "romantis",
      "desc": "",
      "profileThumb": "",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    },
    {
      "id": "57155",
      "title": "romance",
      "desc": "",
      "profileThumb": "",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    },
    {
      "id": "1630284807035909",
      "title": "fyptiktok",
      "desc": "",
      "profileThumb": "",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    },
    {
      "id": "67447817",
      "title": "anhong",
      "desc": "",
      "profileThumb": "",
      "coverThumb": "",
      "isCommerce": false,
      "stats": {
        "videoCount": 0,
        "viewCount": 0
      }
    }
  ],
  "warnInfo": [],
  "originalItem": false,
  "officalItem": false,
  "comments": [
    {
      "cid": "7177241965708493595",
      "text": "lks support",
      "aweme_id": "7167271500058234139",
      "create_time": 1671081889,
      "comment_language": "en",
      "digg_count": 0,
      "reply_comment_total": 0,
      "share_info": {
        "url": "https://m.tiktok.com/v/7167271500058234139.html?_d=e64fck7c57i4e5&comment_author_id=7167311497546236954&language=ja-JP&preview_pb=0&share_comment_id=7177241965708493595&share_item_id=7167271500058234139&source=h5_m&u_code=0",
        "acl": {
          "code": 1,
          "extra": "{\"item_share_acl\":\"empty item value\"}"
        },
        "desc": "juragan.sellerindoのコメント: lks support",
        "title": "Apa?? Ternyata pacarku kelly…😱@Kelly 🍒 #drama #dramatiktok #tiktokviral #tiktokshortfilm #romantis #romance #fyptiktok #anhong @Anhong Media International "
      },
      "user": {
        "uid": "7167311497546236954",
        "unique_id": "juragan.sellerindo",
        "nickname": "juragan.sellerindo"
      }
    }
  ],
  "secret": false,
  "shareEnabled": true,
  "showNotPass": false,
  "forFriend": false
}
```

### Requirements

The actor requires access to proxies (.i.e proxies provided by Apify or custom proxies provided by the user).

### Changelog

All notable changes to this project will be documented in this section.
There are no breaking changes to the project.

#### Added

- Added an optional input field `simplifyComments` that simplifies the comments. When the input field is enabled the decrease structure of comments is replaced with the format

```json
{
    "cid": "7118984082901631770",
    "text": "Khaby you are legend...And love from Nepal❤️",
    "uid": "7115738522267632646",
    "unique_id": "pra.jwol",
    "nickname": "Lol"
}
```

- Added an optional input field `earliestDate` that is used to filter videos posted after the latest Date of Oldest Video

- Fixed a bug with post engagement data.

# Actor input Schema

## `videoUrls` (type: `array`):

Add URLs of  videos to be scraped.

## `hashtags` (type: `array`):

List of TikTok hashtags to be scraped

## `profiles` (type: `array`):

Profile name(s) for users to be scraped

## `maxVideosPerPage` (type: `integer`):

The number of results that will be scraped from every hashtag and profile.

## `maxCommentsPerPost` (type: `integer`):

The number of comments that will be scraped from every scraped result. 0 prevents extraction of comments

## `maxRequestRetries` (type: `integer`):

Maximum number of times a page will be retried in case of being blocked or other errors.

## `maxConcurrency` (type: `integer`):

Maximum number of web pages to be open in  parallel

## `proxyConfiguration` (type: `object`):

Fill in proxies to be used by browser. Use default Apify proxies, or use custom proxies

## `simplifyComments` (type: `boolean`):

Return Simplified comment. Reduce the amount of information present in the comments

## `earliestDate` (type: `string`):

Set the date for the oldest video to be scraped

## Actor input object example

```json
{
  "hashtags": [
    "tiktokshortfilm"
  ],
  "maxVideosPerPage": 5,
  "maxCommentsPerPost": 15,
  "maxRequestRetries": 3,
  "maxConcurrency": 5,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "hashtags": [
        "tiktokshortfilm"
    ],
    "maxVideosPerPage": 5,
    "maxCommentsPerPost": 15,
    "maxRequestRetries": 3,
    "maxConcurrency": 5,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "US"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("mcdowell/tiktok").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "hashtags": ["tiktokshortfilm"],
    "maxVideosPerPage": 5,
    "maxCommentsPerPost": 15,
    "maxRequestRetries": 3,
    "maxConcurrency": 5,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("mcdowell/tiktok").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "hashtags": [
    "tiktokshortfilm"
  ],
  "maxVideosPerPage": 5,
  "maxCommentsPerPost": 15,
  "maxRequestRetries": 3,
  "maxConcurrency": 5,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}' |
apify call mcdowell/tiktok --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mcdowell/tiktok"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/2aZUbTgtUqHEsBIDp/builds/fxEX8QOpv6j4rEqyK/openapi.json
