# Tiktok Scraper (`sovanza.inc/tiktok-scraper`) Actor

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

## Pricing

from $3.70 / 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

### What is TikTok Scraper?

TikTok Scraper is an Apify Actor in this repo that collects **public TikTok video metadata** (caption, author, counts, music, cover, URL) from:

- **Hashtags** (`hashtags` → `/tag/...`)  
- **Profiles** (`profiles` → `/@...`)  
- **Search keywords** (`searchQueries`)  
- **Direct video URLs** (`videoUrls` / `startUrls`)

It is built with **Playwright** in the same spirit as **Amazon** / **Agency Vista** actors here (Python + Chromium + Apify dataset).

**Reference (feature & pricing model):** the well-known Store Actor [clockworks/tiktok-scraper](https://apify.com/clockworks/tiktok-scraper). This CloudBots Actor is a **separate implementation**—not a fork of Clockworks’ code. TikTok changes often; for production scale many teams use the Store Actor or extend this one.

➡️ Provide seeds + limits; the Actor discovers video links on listing pages, opens each video, merges **embedded JSON** and **XHR JSON**, and pushes one row per video.

### Why use this Actor?

- **Own the code** in your monorepo (customize fields, logging, proxy rules).  
- **Same deployment pattern** as your other Actors (`Dockerfile`, `INPUT_SCHEMA.json`, dataset schema).  
- Aligns **input ideas** with the Store scraper: hashtags, profiles, search, caps per seed, `maxItems`.

### Features

- Seeds: **`hashtags`**, **`profiles`**, **`searchQueries`**, **`startUrls`** / **`urls`**, **`videoUrls`**.  
- **Discovery**: scrolls listing pages, collects `/video/` links + parses JSON from network and `<script>` embeds (`__UNIVERSAL_DATA_FOR_REHYDRATION__`, `SIGI_STATE`, etc.).  
- **Detail pass**: per-video page with XHR capture + embedded JSON.  
- **Output**: `webVideoUrl`, `text`, `authorMeta`, engagement counts, `musicMeta`, `videoMeta`, `sourceType` / `sourceValue`, `error`.  
- **Apify Proxy**: default **RESIDENTIAL** when available (`proxyConfiguration`, `disableProxy`).  
- **Optional session**: `cookies` (array) or `storageState` (Playwright JSON) so you can pass a logged-in browser export when TikTok shows login/captcha; treat values as **secrets**.

### How to use on Apify

1. Push **`tiktok-scraper/`** as an Actor (or connect Git subfolder).  
2. Build from **`Dockerfile`**.  
3. Set input (see below). Use **RESIDENTIAL proxy** and a **long timeout** for larger `maxItems`.  
4. **Start** → **Dataset**.

#### Input (example)

```json
{
  "hashtags": ["bananas"],
  "profiles": ["tiktok"],
  "searchQueries": ["ootd"],
  "resultsPerPage": 15,
  "maxItems": 25,
  "scrollRoundsPerSeed": 12,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
````

#### Local

```bash
pip install -r requirements.txt
playwright install chromium
python main.py
```

Uses **`INPUT.json`** when Apify input is empty (same pattern as other CloudBots actors).

### Output

One dataset item per video, including:

- **`webVideoUrl`**, **`id`**, **`text`**, **`createTimeISO`**
- **`authorMeta`**: name, nickName, profileUrl, fans, etc.
- **`diggCount`**, **`playCount`**, **`commentCount`**, **`shareCount`**, **`collectCount`**
- **`musicMeta`**, **`videoMeta`**
- **`sourceType`** / **`sourceValue`** (which seed produced the link)
- **`error`** if that video failed after retries

### Limitations

- **Apify Proxy on SDK 3.x** must use `Actor.create_proxy_configuration(actor_proxy_input=...)` (keyword-only). If you see `takes 1 positional argument but 2 were given` in logs, upgrade this Actor’s `main.py`—proxy was disabled and TikTok will often block.
- **TikTok anti-bot** is aggressive; expect blocks without **working residential proxy** and sober rate limits. Optional **`cookies` / `storageState`** help when you supply a valid session, but cookies **expire** and **IP/proxy** must still match what TikTok expects or the session may be rejected.
- **Not** feature parity with [clockworks/tiktok-scraper](https://apify.com/clockworks/tiktok-scraper) (no video file downloads to KV in v0.1, no followers graph, etc.).
- DOM/API shapes **change**; empty datasets may need selector/JSON path updates.
- Respect **TikTok ToS**, **GDPR**, and **Apify** guidelines.

### FAQ

#### How does this relate to clockworks/tiktok-scraper?

Same **problem space** and similar **input concepts**; different **codebase**. Use the Store Actor if you want Apify-maintained scale; use this if you want in-repo control.

#### Do I need an official TikTok API key?

No; this reads **public** web data like typical scrapers.

### SEO Keywords

tiktok scraper apify\
tiktok video metadata\
tiktok hashtag scraper

### Actor permissions

Designed for **limited** scope: default dataset + input only.

### License

MIT (this Actor code).

### Get started

Push to Apify, enable **RESIDENTIAL** proxy, start with small **`maxItems`**, then scale.

# Actor input Schema

## `hashtags` (type: `array`):

Hashtags without # — each opens https://www.tiktok.com/tag/...

## `profiles` (type: `array`):

TikTok usernames (with or without @) or profile URLs

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

Keyword search on TikTok web search

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

TikTok video, profile, tag, or search URLs (Apify request list shapes supported)

## `urls` (type: `array`):

Same as startUrls

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

Direct /@user/video/id links to scrape without listing discovery

## `resultsPerPage` (type: `integer`):

Max video links to collect per hashtag/profile/search seed

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

Cap on unique videos to open and extract (after discovery)

## `scrollRoundsPerSeed` (type: `integer`):

Scroll passes on each tag/profile/search page

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

Apify Proxy; empty uses RESIDENTIAL when available

## `disableProxy` (type: `boolean`):

If true, do not use Apify Proxy (local debugging only)

## `cookies` (type: `array`):

Playwright-style cookies to reduce login/captcha pages. Export from your browser (e.g. sessionid, tt\_chain\_token) for .tiktok.com — treat as secrets; Actor input is stored on Apify.

## `storageState` (type: `object`):

Full Playwright storageState JSON (cookies + localStorage). Export via page.context.storage\_state() or Playwright codegen. If set, overrides the cookies array.

## Actor input object example

```json
{
  "hashtags": [
    "bananas"
  ],
  "resultsPerPage": 20,
  "maxItems": 30,
  "scrollRoundsPerSeed": 12,
  "disableProxy": false,
  "cookies": []
}
```

# 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 = {
    "hashtags": [
        "bananas"
    ],
    "cookies": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("sovanza.inc/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 = {
    "hashtags": ["bananas"],
    "cookies": [],
}

# Run the Actor and wait for it to finish
run = client.actor("sovanza.inc/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 '{
  "hashtags": [
    "bananas"
  ],
  "cookies": []
}' |
apify call sovanza.inc/tiktok-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Tiktok Scraper",
        "description": null,
        "version": "0.0",
        "x-build-id": "YSBrhkE4mCq5MwbEw"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/sovanza.inc~tiktok-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-sovanza.inc-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/sovanza.inc~tiktok-scraper/runs": {
            "post": {
                "operationId": "runs-sync-sovanza.inc-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/sovanza.inc~tiktok-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-sovanza.inc-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": {
                    "hashtags": {
                        "title": "Hashtags",
                        "type": "array",
                        "description": "Hashtags without # — each opens https://www.tiktok.com/tag/...",
                        "items": {
                            "type": "string"
                        }
                    },
                    "profiles": {
                        "title": "Profiles",
                        "type": "array",
                        "description": "TikTok usernames (with or without @) or profile URLs",
                        "items": {
                            "type": "string"
                        }
                    },
                    "searchQueries": {
                        "title": "Search queries",
                        "type": "array",
                        "description": "Keyword search on TikTok web search",
                        "items": {
                            "type": "string"
                        }
                    },
                    "startUrls": {
                        "title": "Start URLs",
                        "type": "array",
                        "description": "TikTok video, profile, tag, or search URLs (Apify request list shapes supported)",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "urls": {
                        "title": "URLs (alias)",
                        "type": "array",
                        "description": "Same as startUrls",
                        "items": {
                            "type": "string"
                        }
                    },
                    "videoUrls": {
                        "title": "Video URLs only",
                        "type": "array",
                        "description": "Direct /@user/video/id links to scrape without listing discovery",
                        "items": {
                            "type": "string"
                        }
                    },
                    "resultsPerPage": {
                        "title": "Results per seed",
                        "minimum": 1,
                        "maximum": 200,
                        "type": "integer",
                        "description": "Max video links to collect per hashtag/profile/search seed",
                        "default": 20
                    },
                    "maxItems": {
                        "title": "Max videos to scrape",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Cap on unique videos to open and extract (after discovery)",
                        "default": 30
                    },
                    "scrollRoundsPerSeed": {
                        "title": "Scroll rounds per listing seed",
                        "minimum": 1,
                        "maximum": 40,
                        "type": "integer",
                        "description": "Scroll passes on each tag/profile/search page",
                        "default": 12
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Apify Proxy; empty uses RESIDENTIAL when available"
                    },
                    "disableProxy": {
                        "title": "Disable proxy",
                        "type": "boolean",
                        "description": "If true, do not use Apify Proxy (local debugging only)",
                        "default": false
                    },
                    "cookies": {
                        "title": "TikTok cookies (optional)",
                        "type": "array",
                        "description": "Playwright-style cookies to reduce login/captcha pages. Export from your browser (e.g. sessionid, tt_chain_token) for .tiktok.com — treat as secrets; Actor input is stored on Apify."
                    },
                    "storageState": {
                        "title": "Playwright storage state (optional)",
                        "type": "object",
                        "description": "Full Playwright storageState JSON (cookies + localStorage). Export via page.context.storage_state() or Playwright codegen. If set, overrides the cookies array."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
