# TikTok Scraper (`scrapemesh/tiktok-scraper`) Actor

- **URL**: https://apify.com/scrapemesh/tiktok-scraper.md
- **Developed by:** [ScrapeMesh](https://apify.com/scrapemesh) (community)
- **Categories:** Automation, Lead generation, Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

A powerful Apify Actor for scraping TikTok profiles, videos, reposts, hashtags, and keyword search results with automatic proxy fallback.

### Why Choose Us?

- **Comprehensive Scraping**: Scrape videos, reposts, hashtags, and keyword searches in one actor
- **Automatic Proxy Fallback**: Intelligently handles blocks with automatic proxy switching (none → datacenter → residential)
- **Live Data Saving**: Results are saved immediately as they're scraped
- **Bulk Processing**: Process multiple profiles and queries in a single run
- **Robust Error Handling**: Graceful error handling with detailed logging

### Key Features

- ✅ **Profile Video Scraping**: Extract all videos from TikTok profiles
- ✅ **Repost Scraping**: Get reposted content from profiles
- ✅ **Hashtag Search**: Search and scrape content by hashtags
- ✅ **Keyword Search**: Search TikTok by keywords
- ✅ **Automatic Proxy Management**: Smart fallback from no proxy → datacenter → residential
- ✅ **Real-time Logging**: Detailed logs to track scraping progress
- ✅ **Bulk Input Support**: Process multiple URLs/usernames at once

### Input

#### Example Input JSON

```json
{
  "startUrls": [
    { "url": "https://www.tiktok.com/@mrbeast" },
    { "url": "https://www.tiktok.com/@nike" }
  ],
  "profileScrapeSections": ["videos", "repost"],
  "searchQuery": "Ronaldo",
  "searchType": "keyword",
  "maxResults": 100,
  "proxyConfiguration": {}
}
````

#### Input Fields

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `startUrls` | Array | Yes | List of TikTok profile URLs or usernames |
| `profileScrapeSections` | Array | No | Sections to scrape: `["videos", "repost"]` (default: `["videos"]`) |
| `searchQuery` | String | No | Search query for hashtag/keyword search (leave empty to skip) |
| `searchType` | String | No | `"keyword"` or `"hashtag"` (default: `"keyword"`) |
| `maxResults` | Integer | No | Maximum results per profile/query (1-1000, default: 100) |
| `proxyConfiguration` | Object | No | Proxy settings (optional, automatic fallback enabled) |

### Output

The actor outputs structured data to the Apify dataset. Each item includes:

- **Type**: Type of scraped data (profile\_video, profile\_repost, hashtag\_search, keyword\_search)
- **Username/Query**: The username or search query
- **Data**: The actual scraped content (video details, repost info, etc.)
- **Success**: Whether the scraping was successful

#### Example Output

```json
{
  "type": "profile_video",
  "username": "mrbeast",
  "video": {
    "id": "7234567890123456789",
    "url": "https://www.tiktok.com/@mrbeast/video/7234567890123456789",
    "title": "Video description",
    "create_time": 1234567890,
    "author": {
      "username": "mrbeast",
      "nickname": "MrBeast",
      "verified": true
    },
    "stats": {
      "views": 1000000,
      "likes": 50000,
      "comments": 1000,
      "shares": 500
    }
  },
  "success": true
}
```

### 🚀 How to Use the Actor (via Apify Console)

1. Log in at https://console.apify.com and go to **Actors**
2. Find **tiktok-scraper** and click it
3. Configure inputs:
   - Add TikTok profile URLs or usernames in `startUrls`
   - Select which sections to scrape (`videos`, `repost`)
   - Optionally add a search query
   - Set maximum results
   - Configure proxy if needed (or leave empty for automatic fallback)
4. Click **Start** to run the actor
5. Monitor logs in real time to see scraping progress
6. Access results in the **OUTPUT** tab
7. Export results to JSON or CSV

### Best Use Cases

- **Content Research**: Scrape videos from competitor profiles
- **Trend Analysis**: Search hashtags and keywords to track trends
- **Influencer Research**: Collect data from multiple influencer profiles
- **Content Aggregation**: Gather videos and reposts for analysis
- **Market Research**: Search for specific topics and keywords

### Frequently Asked Questions

**Q: What happens if TikTok blocks my requests?**\
A: The actor automatically falls back through proxy tiers: no proxy → datacenter → residential. All proxy events are logged clearly. The actor will retry 3 times with residential proxy if needed.

**Q: Can I scrape private accounts?**\
A: No, the actor only scrapes publicly available content.

**Q: How many profiles can I scrape at once?**\
A: You can add unlimited profiles in the `startUrls` array. The actor processes them sequentially.

**Q: What's the difference between keyword and hashtag search?**\
A: Keyword search searches TikTok's general search, while hashtag search specifically targets hashtag pages.

**Q: How long does scraping take?**\
A: Depends on the number of profiles/queries and max results. The actor processes items as fast as possible while respecting rate limits.

**Q: Does the actor save data as it scrapes?**\
A: Yes! The actor uses live saving - data is pushed to the dataset immediately as it's scraped, so you won't lose data if the actor crashes.

### Support and Feedback

For issues, questions, or feedback, please contact support through the Apify platform.

### Cautions

- Data is collected only from **publicly available sources**
- No data is taken from private accounts or password-protected content
- The end user is responsible for ensuring legal compliance (spam laws, privacy, data protection, etc.)
- Respect TikTok's Terms of Service and rate limits

# Actor input Schema

## `startUrls` (type: `array`):

📋 Add TikTok profile URLs (e.g., https://www.tiktok.com/@username) or just usernames (e.g., username). Supports bulk input - add as many profiles as you want! 💪 Leave empty if you only want to do search scraping.

## `profileScrapeSections` (type: `array`):

🎯 Choose which sections to scrape from profiles: 📺 'videos' (all profile videos) and/or 🔄 'repost' (reposted content). Select one or both!

## `searchQuery` (type: `string`):

🔎 Enter a search query for hashtag or keyword search. Leave empty if you only want to scrape profiles. Examples: 'Ronaldo', '#travel', 'cooking tips'

## `searchType` (type: `string`):

📌 Choose search type: 🔑 'keyword' (general TikTok search) or #️⃣ 'hashtag' (hashtag-specific search). Default: keyword

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

🎯 Maximum number of results to collect per profile/search query. Range: 1-1000. Higher values = more data but longer scraping time. ⏱️

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

🔒 Proxy settings for enhanced reliability. By default, no proxy is used (direct connection). If TikTok blocks requests, the actor automatically falls back: no proxy → datacenter → residential proxy. 🛡️ Smart protection!

## Actor input object example

```json
{
  "startUrls": [
    "https://www.tiktok.com/@mrbeast"
  ],
  "profileScrapeSections": [
    "videos"
  ],
  "searchQuery": "",
  "searchType": "keyword",
  "maxResults": 100,
  "proxyConfiguration": {}
}
```

# 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 = {
    "startUrls": [
        "https://www.tiktok.com/@mrbeast"
    ],
    "profileScrapeSections": [
        "videos"
    ],
    "proxyConfiguration": {}
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapemesh/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 = {
    "startUrls": ["https://www.tiktok.com/@mrbeast"],
    "profileScrapeSections": ["videos"],
    "proxyConfiguration": {},
}

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

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

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

```

## CLI example

```bash
echo '{
  "startUrls": [
    "https://www.tiktok.com/@mrbeast"
  ],
  "profileScrapeSections": [
    "videos"
  ],
  "proxyConfiguration": {}
}' |
apify call scrapemesh/tiktok-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scrapemesh/tiktok-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "TikTok Scraper",
        "version": "0.1",
        "x-build-id": "63Jk18VicZP99554L"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrapemesh~tiktok-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrapemesh-tiktok-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/scrapemesh~tiktok-scraper/runs": {
            "post": {
                "operationId": "runs-sync-scrapemesh-tiktok-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/scrapemesh~tiktok-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-scrapemesh-tiktok-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "startUrls": {
                        "title": "👤 TikTok Profile URLs or Usernames",
                        "type": "array",
                        "description": "📋 Add TikTok profile URLs (e.g., https://www.tiktok.com/@username) or just usernames (e.g., username). Supports bulk input - add as many profiles as you want! 💪 Leave empty if you only want to do search scraping.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "profileScrapeSections": {
                        "title": "📹 Profile Scrape Sections",
                        "type": "array",
                        "description": "🎯 Choose which sections to scrape from profiles: 📺 'videos' (all profile videos) and/or 🔄 'repost' (reposted content). Select one or both!",
                        "items": {
                            "type": "string",
                            "enum": [
                                "videos",
                                "repost"
                            ]
                        },
                        "default": [
                            "videos"
                        ]
                    },
                    "searchQuery": {
                        "title": "🔍 Search Query",
                        "type": "string",
                        "description": "🔎 Enter a search query for hashtag or keyword search. Leave empty if you only want to scrape profiles. Examples: 'Ronaldo', '#travel', 'cooking tips'",
                        "default": ""
                    },
                    "searchType": {
                        "title": "🏷️ Search Type",
                        "enum": [
                            "keyword",
                            "hashtag"
                        ],
                        "type": "string",
                        "description": "📌 Choose search type: 🔑 'keyword' (general TikTok search) or #️⃣ 'hashtag' (hashtag-specific search). Default: keyword",
                        "default": "keyword"
                    },
                    "maxResults": {
                        "title": "📊 Maximum Results",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "🎯 Maximum number of results to collect per profile/search query. Range: 1-1000. Higher values = more data but longer scraping time. ⏱️",
                        "default": 100
                    },
                    "proxyConfiguration": {
                        "title": "🌐 Proxy Configuration",
                        "type": "object",
                        "description": "🔒 Proxy settings for enhanced reliability. By default, no proxy is used (direct connection). If TikTok blocks requests, the actor automatically falls back: no proxy → datacenter → residential proxy. 🛡️ Smart protection!"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
