# TikTok Search Scraper (`alien_force/tiktok-search-scraper`) Actor

Scrape all public TikTok videos that use a given music/sound URL. Get captions, stats, covers, author profiles, and music details with pagination and proxy support.

- **URL**: https://apify.com/alien\_force/tiktok-search-scraper.md
- **Developed by:** [Alien Force](https://apify.com/alien_force) (community)
- **Stats:** 3 total users, 2 monthly users, 50.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.60 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Search Scraper

### Overview

**Scrape TikTok search results by keyword** — videos, photos, or users — in one Apify Actor.

The **TikTok Search Scraper** turns any public TikTok search query into clean, structured data: captions, views, likes, covers, music, author profiles, and more. Use it for content research, trend monitoring, influencer discovery, competitor tracking, or bulk export to CSV/JSON and your own pipelines.

Whether you need TikTok video search results, photo/carousel posts, or user profiles matching a keyword, you get paginated results with optional sort and date filters — without manual scrolling.

#### Key Features

- **TikTok keyword search scraper**: Run one search query and pull public results at scale.
- **Videos, photos, and users**: Scrape TikTok search tabs for video posts, image posts, or creator profiles.
- **Trend & content research ready**: Capture captions, engagement stats, covers, play URLs, and music metadata.
- **Influencer / user discovery**: Find TikTok accounts by keyword with follower counts, bios, and profile links.
- **Sort and date filters**: Relevance, most liked, or latest — plus date-posted windows (videos and photos).
- **Pagination to your limit**: Keep fetching until you hit your max results or TikTok runs out of pages.
- **Proxy support**: Datacenter proxies by default; switch to residential if TikTok starts blocking.
- **Clear run reporting**: Empty or blocked outcomes stay out of the dataset and show up in logs / a key-value report.

***

### Input Schema

#### Input Properties

1. **`searchQuery`**

   - **Type**: `string` (required)
   - **Description**: Keyword or phrase to search on TikTok (single query per run).
   - **Example**: `"the rock"`

2. **`searchType`**

   - **Type**: `string`
   - **Description**: Which search results to scrape: `videos`, `photos`, or `users`. Default is `videos`.
   - **Example**: `"videos"`

3. **`limit`**

   - **Type**: `integer`
   - **Description**: Maximum number of results to scrape for the run. Set to `0` for no soft cap (the run still stops when TikTok reports no more results). Default is `10`.
   - **Example**: `100`

4. **`sortType`**

   - **Type**: `string`
   - **Description**: Sort preference for videos and photos: `relevance`, `mostLiked`, or `latest`. Default is `relevance`. Ignored for `users`.
   - **Example**: `"mostLiked"`

5. **`datePosted`**

   - **Type**: `string`
   - **Description**: Publish-time filter for videos and photos: `all`, `24h`, `week`, `month`, `3months`, or `6months`. Default is `all`. Ignored for `users`.
   - **Example**: `"week"`

6. **`proxyConfiguration`**

   - **Type**: `object`
   - **Description**: Use Apify `RESIDENTIAL` proxies. Optionally pick a **Country** in the proxy dropdown — that ISO code drives TikTok `region` / timezone so they match the exit IP (full Apify residential country list supported).
   - **Example**:
     ```json
     { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"], "apifyProxyCountry": "US" }
     ```

`searchQuery` is required.

#### Input Example

```json
{
    "searchQuery": "the rock",
    "searchType": "videos",
    "limit": 100,
    "sortType": "relevance",
    "datePosted": "all",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US"
    }
}
```

***

### Output

One dataset row per result. The shape depends on `searchType`.

#### Common fields

| Field | Type | Description |
| --- | --- | --- |
| `searchType` | string | `videos`, `photos`, or `users` |
| `searchQuery` | string | Search query used for the run |

#### Videos (`searchType: "videos"`)

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Video ID |
| `desc` | string | null | Caption |
| `createTime` | integer | null | Create time (Unix timestamp, seconds) |
| `url` | string | null | Canonical video URL |
| `author` | object | null | Author details (`id`, `uniqueId`, `nickname`, `signature`, `verified`, `avatarThumb`, `secUid`) |
| `stats` | object | null | Engagement (`diggCount`, `shareCount`, `commentCount`, `playCount`, `collectCount`) |
| `music` | object | null | Music / sound (`id`, `title`, `authorName`, `playUrl`) |
| `video` | object | null | Media (`id`, `duration`, `cover`, `playAddr`, `downloadAddr`, `width`, `height`) |

#### Photos (`searchType: "photos"`)

Same as videos for `id`, `desc`, `createTime`, `url`, `author`, `stats`, and `music`, plus:

| Field | Type | Description |
| --- | --- | --- |
| `imagePost` | object | null | Photo post (`title`, `cover`, `images[]` with `imageURL`) |

#### Users (`searchType: "users"`)

| Field | Type | Description |
| --- | --- | --- |
| `uid` | string | null | User ID |
| `uniqueId` | string | Username handle |
| `nickname` | string | null | Display name |
| `signature` | string | null | Bio |
| `followerCount` | integer | null | Follower count |
| `heartCount` | integer | null | Total likes on the profile |
| `verified` | boolean | null | Verified flag |
| `avatar` | string | null | Avatar URL |
| `secUid` | string | null | Stable account ID |
| `profileUrl` | string | null | Canonical profile URL |

#### Output Example (videos)

```json
{
    "searchType": "videos",
    "searchQuery": "the rock",
    "id": "7635425590299970838",
    "desc": "Mae Young > Marilyn Monroe The Rock is one lucky birthday boy! ...",
    "createTime": 1777761063,
    "url": "https://www.tiktok.com/@onthisdayinwwe/video/7635425590299970838",
    "author": {
        "id": "7050958181346116614",
        "uniqueId": "onthisdayinwwe",
        "nickname": "OnThisDayInWWE",
        "signature": "Milestone moments in WWE history...",
        "verified": false,
        "avatarThumb": "https://...",
        "secUid": "MS4wLjABAAAA..."
    },
    "stats": {
        "diggCount": 377,
        "shareCount": 30,
        "commentCount": 3,
        "playCount": 75000,
        "collectCount": 54
    },
    "music": {
        "id": "7635425604015229719",
        "title": "original sound",
        "authorName": "OnThisDayInWWE",
        "playUrl": "https://..."
    },
    "video": {
        "id": "7635425590299970838",
        "duration": 111,
        "cover": "https://...",
        "playAddr": "https://...",
        "downloadAddr": null,
        "width": 576,
        "height": 1024
    }
}
```

#### Output Example (users)

```json
{
    "searchType": "users",
    "searchQuery": "avengers",
    "uid": "6589561205014249478",
    "uniqueId": "raviprajapati0012",
    "nickname": "Avengers official",
    "signature": "Avengers lover",
    "followerCount": 23700,
    "heartCount": 746758,
    "verified": false,
    "avatar": "https://...",
    "secUid": "MS4wLjABAAAA...",
    "profileUrl": "https://www.tiktok.com/@raviprajapati0012"
}
```

Some media fields (for example `video.downloadAddr`) may be `null` when TikTok does not include them in the response. Play and cover URLs can expire; fetch them promptly if you need the files.

#### Handling of empty and blocked runs

Failed or empty outcomes are kept out of the dataset and reported in the **`REPORT`** record in the run's key-value store (when skips are recorded), alongside warnings or errors in the log.

- **No results for the query**: the run fails after a session refresh attempt. Use a different query, loosen filters, or check proxies.
- **Blocked / empty upstream responses**: automatically retried. If nothing could be scraped, the run fails with a clear message suggesting residential proxies.
- **Partial success**: if some pages succeed and later pages stop, rows already saved stay in the dataset.

The run's status message reports how many results were scraped and how many issues were skipped.

# Actor input Schema

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

Keyword or phrase to search on TikTok (single query per run).

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

Which TikTok search tab to scrape.

## `limit` (type: `integer`):

Maximum number of results to scrape. Set to 0 for no soft cap (TikTok still stops when has\_more is false). Default is 10.

## `sortType` (type: `string`):

Sort preference sent to the search API.

## `datePosted` (type: `string`):

Publish-time filter sent to the search API.

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

Use Apify RESIDENTIAL proxies. Optionally pick a Country in the proxy dropdown — that ISO code is sent as TikTok region/timezone so it matches the exit IP (all Apify residential countries are supported).

## Actor input object example

```json
{
  "searchQuery": "cat",
  "searchType": "videos",
  "limit": 10,
  "sortType": "relevance",
  "datePosted": "all",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# 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 = {
    "searchQuery": "cat",
    "searchType": "videos",
    "limit": 10,
    "sortType": "relevance",
    "datePosted": "all",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alien_force/tiktok-search-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 = {
    "searchQuery": "cat",
    "searchType": "videos",
    "limit": 10,
    "sortType": "relevance",
    "datePosted": "all",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("alien_force/tiktok-search-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 '{
  "searchQuery": "cat",
  "searchType": "videos",
  "limit": 10,
  "sortType": "relevance",
  "datePosted": "all",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call alien_force/tiktok-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alien_force/tiktok-search-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/2cpzsllRrovuBGJ1W/builds/Lk9YbAcA02sNMUzB2/openapi.json
