# TikTok Public Post Scraper (`w3crawler/tiktok-post-scraper`) Actor

Scrape visible public TikTok video cards from a hashtag or search page with Playwright and return captions, creators, visible engagement text, music, duration, and thumbnails.

- **URL**: https://apify.com/w3crawler/tiktok-post-scraper.md
- **Developed by:** [w3crawler](https://apify.com/w3crawler) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 posts

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

## TikTok Public Search Video Scraper

Scrape visible public TikTok video cards from a hashtag page or TikTok search page. The Actor uses Playwright, bounded scrolling, and public DOM selectors to extract video IDs, URLs, creator information, captions, visible engagement text, music, duration, and thumbnails.

Despite the historical directory name, this implementation does not accept individual post URLs. It is a public search/hashtag card scraper and does not use account cookies, access private content, or bypass authentication, CAPTCHAs, or other access controls.

### Example input

```json
{
  "query": "street food",
  "maxItems": 10,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

Hashtag mode:

```json
{
  "hashtag": "dance",
  "maxItems": 10
}
```

If both `hashtag` and `query` are supplied, hashtag mode takes precedence.

### Example output

```json
{
  "recordType": "tiktok-video",
  "status": "success",
  "dataAvailable": true,
  "source": "tiktok.com",
  "provenance": "public_search_or_hashtag_page",
  "sourceTransport": "playwright",
  "extractionMethod": "search_card_dom",
  "sourceUrl": "https://www.tiktok.com/search?q=street%20food",
  "videoId": "1234567890",
  "url": "https://www.tiktok.com/@creator/video/1234567890",
  "authorUsername": "creator",
  "description": "A public caption",
  "playCount": "12K",
  "likeCount": "900",
  "commentCount": "45",
  "shareCount": "20",
  "searchType": "search",
  "scrapedAt": "2026-08-18T00:00:00.000Z"
}
```

When TikTok returns a challenge, the page has no recognizable cards, or the request fails, a `tiktok-post-access-diagnostic` record is written. The `OUTPUT` key-value record reports the final status.

### Input

- `query` (string): Public TikTok search phrase, maximum 120 characters.
- `hashtag` (string): Hashtag without the leading `#`; letters, numbers, underscores, and hyphens are accepted. Hashtag takes precedence.
- `maxItems` (integer, 1–200): Maximum unique visible video records. Default: `30`.
- `proxyConfiguration` (object, optional): Apify Proxy configuration for public page access.

At least one of `query` or `hashtag` is required.

### Output and storage

Video records and access diagnostics are written to the default dataset. The Output tab links to the dataset and to `OUTPUT` in the default key-value store. A bounded `debug_html` key may also be written when a page is blocked or empty.

`OUTPUT` contains the selected public URL, search mode, query/hashtag, requested limit, stored video count, failed URLs, empty-page count, blocked-page count, and final status.

### Limitations and cost

The Actor reads visible cards after bounded scrolling. TikTok may return different markup, partial results, or a challenge page. Engagement values remain visible text such as `12K` or `1.2M`; they are not silently converted to numbers.

Browser compute and proxy traffic are the main costs. Start with a small `maxItems` value and avoid high-frequency retries.

### FAQ and disclaimer

#### Does this Actor scrape an individual post URL?

No. Use a public search phrase or hashtag; the current implementation extracts cards from that result page.

#### Why are there no video rows?

TikTok may have returned a challenge, an empty page, or markup that no longer matches the selectors. Check the diagnostic and `OUTPUT` record.

#### Does it bypass bot detection?

No. It detects challenge pages and records them; it does not solve or defeat them.

Use results only for a legitimate purpose, follow TikTok terms and robots guidance, and review privacy and data-protection obligations. For support, use the Actor Issues tab.

# Changelog

This Actor's version history is a separate document: https://apify.com/w3crawler/tiktok-post-scraper/changelog.md

# Actor input Schema

## `query` (type: `string`):

Public TikTok search phrase, maximum 120 characters.

## `hashtag` (type: `string`):

Hashtag without the leading #. Letters, numbers, underscores, and hyphens are accepted.

## `maxItems` (type: `integer`):

Maximum number of unique visible video records to store.

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

Optional Apify Proxy configuration for public TikTok page access.

## Actor input object example

```json
{
  "query": "dancing",
  "hashtag": "dance",
  "maxItems": 10,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

## `debugHtml` (type: `string`):

Bounded HTML captured when a TikTok post page is blocked or empty.

# 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 = {
    "query": "dancing",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("w3crawler/tiktok-post-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 = {
    "query": "dancing",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("w3crawler/tiktok-post-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 '{
  "query": "dancing",
  "maxItems": 10
}' |
apify call w3crawler/tiktok-post-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,w3crawler/tiktok-post-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/TRoTWaFUZiy77hzVW/builds/U2m4zPjXrPBGQgCdo/openapi.json
