# TikTok Scraper — Videos, Profiles, Comments & Trends (`magicfingers/tiktok-scraper`) Actor

Scrape TikTok data at scale: search videos by keyword/hashtag, scrape user profiles, video details with stats, comments, and trending hashtags. Returns clean JSON with full metadata.

- **URL**: https://apify.com/magicfingers/tiktok-scraper.md
- **Developed by:** [abdulrahman alrashid](https://apify.com/magicfingers) (community)
- **Categories:** Marketing
- **Stats:** 65 total users, 8 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## TikTok Scraper — Videos, Profiles, Comments & Trends

Scrape TikTok data at scale. Search videos by keyword or hashtag, scrape user profiles and their video lists, get full video details with stats, extract comments, and discover trending hashtags.

### Features

| Mode | Description | Output |
|------|-------------|--------|
| `SEARCH_VIDEOS` | Search by keyword or #hashtag | Videos with description, stats, author, music, URL |
| `USER_PROFILE` | Scrape user profile | Username, bio, follower/following/like counts, verified status |
| `USER_VIDEOS` | List all videos from a user | Full video list with stats |
| `VIDEO_DETAILS` | Get full details for specific videos | Description, stats, music, hashtags, effects |
| `VIDEO_COMMENTS` | Extract comments from videos | Comment text, author, likes, replies count, date |
| `TRENDING_HASHTAGS` | Discover trending hashtags | Hashtag name, view count, video count |

### Input Examples

#### Search Videos

```json
{
    "mode": "SEARCH_VIDEOS",
    "searchQueries": ["#fitness", "cooking recipes"],
    "maxResults": 100,
    "sortBy": "likes"
}
```

#### Scrape User Profile

```json
{
    "mode": "USER_PROFILE",
    "usernames": ["charlidamelio", "khaby.lame"]
}
```

#### Scrape User Videos

```json
{
    "mode": "USER_VIDEOS",
    "usernames": ["charlidamelio"],
    "maxResults": 200
}
```

#### Video Details

```json
{
    "mode": "VIDEO_DETAILS",
    "videoUrls": ["https://www.tiktok.com/@user/video/1234567890"]
}
```

#### Video Comments

```json
{
    "mode": "VIDEO_COMMENTS",
    "videoUrls": ["https://www.tiktok.com/@user/video/1234567890"],
    "maxCommentsPerVideo": 500
}
```

#### Trending Hashtags

```json
{
    "mode": "TRENDING_HASHTAGS",
    "maxResults": 50
}
```

### Output Examples

#### Video

```json
{
    "id": "7234567890123456789",
    "description": "Amazing recipe! #cooking #food",
    "createTime": "2024-01-15T10:30:00.000Z",
    "author": {
        "uniqueId": "chefmike",
        "nickname": "Chef Mike",
        "verified": true
    },
    "stats": {
        "views": 1500000,
        "likes": 250000,
        "comments": 3200,
        "shares": 15000,
        "saves": 45000
    },
    "music": {
        "title": "original sound",
        "author": "Chef Mike"
    },
    "video": {
        "url": "https://www.tiktok.com/@chefmike/video/7234567890123456789",
        "duration": 45
    },
    "hashtags": ["cooking", "food"]
}
```

#### User Profile

```json
{
    "username": "charlidamelio",
    "displayName": "Charli D'Amelio",
    "bio": "don't you dare",
    "verified": true,
    "stats": {
        "followers": 155000000,
        "following": 1200,
        "likes": 11500000000,
        "videos": 2500
    }
}
```

### Technical Details

- **Anti-bot evasion**: Stealth mode with webdriver flag removal, navigator spoofing, canvas/WebGL fingerprint masking, and human-like behavior simulation.
- **Data extraction**: Dual approach — intercepts TikTok internal API responses via Playwright route interception AND extracts from `__UNIVERSAL_DATA_FOR_REHYDRATION__` embedded page data.
- **Pagination**: Automatic scrolling with configurable limits. Handles infinite scroll patterns.
- **Proxies**: Residential proxies strongly recommended (TikTok aggressively blocks datacenter IPs).

### Pricing

Pay-Per-Event: **$0.25 per 1,000 results** ($0.00025 per result)

### Proxy Configuration

TikTok blocks datacenter proxies aggressively. Use Apify residential proxies for best results:

```json
{
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": ["RESIDENTIAL"]
    }
}
```

### Limitations

- TikTok frequently changes its internal API and page structure. The scraper handles multiple data formats to maximize reliability.
- Private accounts cannot be scraped.
- Some regions may require specific proxy locations.
- Rate limits apply — the scraper uses delays and session rotation to stay under limits.

# Actor input Schema

## `mode` (type: `string`):

What to scrape from TikTok.

## `searchQueries` (type: `array`):

Keywords or hashtags to search for (SEARCH\_VIDEOS mode). Prefix with # for hashtag search.

## `usernames` (type: `array`):

TikTok usernames to scrape (USER\_PROFILE or USER\_VIDEOS mode). Without the @ symbol.

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

Full TikTok video URLs (VIDEO\_DETAILS or VIDEO\_COMMENTS mode).

## `maxResults` (type: `integer`):

Maximum number of results to return per query/username/video.

## `maxCommentsPerVideo` (type: `integer`):

Maximum comments to scrape per video (VIDEO\_COMMENTS mode).

## `sortBy` (type: `string`):

How to sort search results.

## `publishedAfter` (type: `string`):

Only return content published after this date (YYYY-MM-DD format).

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

Proxy settings. Residential proxies strongly recommended for TikTok.

## Actor input object example

```json
{
  "mode": "SEARCH_VIDEOS",
  "searchQueries": [
    "#fitness",
    "cooking recipes",
    "#tech"
  ],
  "usernames": [
    "charlidamelio",
    "khaby.lame"
  ],
  "videoUrls": [
    "https://www.tiktok.com/@user/video/1234567890"
  ],
  "maxResults": 5,
  "maxCommentsPerVideo": 100,
  "sortBy": "relevance",
  "publishedAfter": "2024-01-01",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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 = {
    "searchQueries": [
        "cooking"
    ],
    "maxResults": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("magicfingers/tiktok-scraper").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 = {
    "searchQueries": ["cooking"],
    "maxResults": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("magicfingers/tiktok-scraper").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 '{
  "searchQueries": [
    "cooking"
  ],
  "maxResults": 5
}' |
apify call magicfingers/tiktok-scraper --silent --output-dataset

```

## MCP server setup

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

```

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/hRqd7y8wyLnzaScbs/builds/FxMKtMHdu2E9fUB0s/openapi.json
