# TikTok Public Hashtag and Search Video Scraper (`w3crawler/tiktok-hashtag-scraper`) Actor

Scrape public TikTok hashtag or search result pages with Playwright and return visible video-card metadata, author, music, and engagement fields.

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

## Pricing

from $2.99 / 1,000 hashtag videos

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 Hashtag and Search Video Scraper

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

It does not use account cookies, access private content, or bypass authentication, CAPTCHAs, or other access controls.

### Example input

Hashtag mode:

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

Search mode:

```json
{
  "query": "street food",
  "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/tag/dance",
  "videoId": "1234567890",
  "url": "https://www.tiktok.com/@creator/video/1234567890",
  "authorUsername": "creator",
  "description": "A public caption #dance",
  "hashtags": ["dance"],
  "playCount": "12K",
  "likeCount": "900",
  "commentCount": "45",
  "shareCount": "20",
  "searchType": "hashtag",
  "scrapedAt": "2026-08-18T00:00:00.000Z"
}
```

When TikTok returns a challenge, the page has no recognizable video cards, or the request fails, the dataset receives a `tiktok-hashtag-access-diagnostic` record. The `OUTPUT` key-value record reports the failure or partial status.

### Input

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

At least one of `hashtag` or `query` 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 the page is blocked or empty to aid troubleshooting.

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

### Limitations and cost

The Actor reads what is visible in the public search or hashtag page after bounded scrolling. TikTok may return different markup, partial results, or a challenge page depending on region, time, and traffic. Engagement values are visible text and may include suffixes such as `K` or `M`; they are not silently converted.

Browser compute and proxy traffic are the main costs. Start with a small `maxItems` value, use a permitted proxy configuration only when needed, and avoid high-frequency retries.

### FAQ and disclaimer

#### Does it scrape private videos or use a logged-in feed?

No. It uses public search or hashtag pages only.

#### Why are there no video rows?

TikTok may have returned a challenge, an empty page, or markup that no longer matches the DOM 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. Public video metadata can still contain personal data. For support, use the Actor Issues tab.

# Changelog

This Actor's version history is a separate document: https://apify.com/w3crawler/tiktok-hashtag-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. Use only a proxy configuration permitted by your account and the target website.

## 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 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-hashtag-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-hashtag-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-hashtag-scraper --silent --output-dataset

```

## MCP server setup

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