# TikTok Viral Hook Analyzer: Reels & Shorts Scraper + AI (`ingeniela/tiktok-viral-hook-analyzer`) Actor

Find the hooks behind the most viral TikToks, Instagram Reels and YouTube Shorts in any niche: the first 3 seconds, hook type, how each video beat its creator's average, why it works, templates and new hooks.

- **URL**: https://apify.com/ingeniela/tiktok-viral-hook-analyzer.md
- **Developed by:** [Ingeniela](https://apify.com/ingeniela) (community)
- **Categories:** Social media, AI, Videos
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 analyzed videos

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Viral Hook Analyzer: TikTok, Instagram Reels and YouTube Shorts with AI

Find out why the top videos in your niche get watched. The Actor collects the most viewed TikToks, Instagram Reels or YouTube Shorts for your hashtags, searches or competitor profiles, reads the first 3 seconds of each one (the hook), classifies the hook, and tells you which kinds of hook get the most views. With AI insights on, every hook comes with why it works, a reusable template, and two new hooks written for your niche, plus a playbook for the whole run.

![HTML report of a real run: hook types ranked by median views, best video length and the top 15 hooks](https://api.apify.com/v2/key-value-stores/RXaOr7FspyrQ4JP88/records/tiktok-viral-hook-analyzer-report-en.png)

*Real report from a run on #skincare and #skincareroutine (18 videos, 6 ads skipped), with AI insights off. A POV hook got 1.99× the median views. With AI insights on, each hook also gets why it works, a reusable template and new hooks for your niche, and the report starts with a playbook.*

### Tutorial (1 minute)

![Step-by-step tutorial: what to fill in, click Start, the real result and the price](https://api.apify.com/v2/key-value-stores/RXaOr7FspyrQ4JP88/records/viral-hook-analyzer-tutorial.gif)

*Every result in this tutorial comes from a real run.*

### What you get

- **Three platforms**: TikTok, **Instagram Reels** and **YouTube Shorts** (choose in *Platform*).
- **The spoken hook**, taken from the subtitles (first 3 seconds) on TikTok and YouTube Shorts, or the caption's first line when a video has no subtitles.
- **On-screen text** (optional, AI vision): the words written on the cover / first frame. When a video has no spoken hook, that text becomes the hook. Ideal for Reels.
- **Versus the creator's own average**: each video's views divided by its creator's median views in the run (`viewsVsCreatorMedian`). A video at 4× its creator's median is a real outlier, not just a big account. The report lists the top outliers.
- **Hook type** in 12 categories: warning, secret, list, how-to, POV, before/after, story, hot take, calls out the viewer, question, outcome promise, direct statement. Spanish and English.
- **Performance per hook type**: median views, engagement and lift against the run's median.
- **Length analysis**: which video lengths get the most views.
- **AI insights** (optional): why each hook works, a template with blanks, 2 rewrites for your niche and brand.
- **Playbook**: the 3-5 patterns that win in this niche, 10 hook ideas to film this week, do's and don'ts.
- **HTML report** in the key-value store (`REPORT`), and the full summary as JSON (`SUMMARY`).

### Input example

```json
{
  "hashtags": ["skincare", "rutinadeskincare"],
  "profiles": ["competitor_brand"],
  "videosPerSource": 30,
  "minViews": 10000,
  "yourNiche": "skincare con péptidos para mujeres 30+",
  "yourBrand": "Pepfine",
  "reportLanguage": "es"
}
```

### Output (one row per video)

```json
{
  "videoUrl": "https://www.tiktok.com/@creator/video/123",
  "hook": "Deja de usar vitamina C así si tienes piel sensible",
  "hookSource": "spoken",
  "hookType": "warning",
  "views": 1250000,
  "engagementRate": 0.087,
  "aiWhyItWorks": "Señala un error que el espectador puede estar cometiendo, así que se queda para saber cuál es.",
  "aiTemplate": "Deja de usar [INGREDIENTE] así si tienes [PROBLEMA]",
  "aiRewrites": ["Deja de aplicar péptidos así si tienes piel madura", "..."],
  "durationSeconds": 22,
  "author": "creator"
}
```

### How to use it

1. Add 1-3 **hashtags** of your niche and, if you want, 3-5 **competitor profiles**.
2. Write **Your niche** in one line (for example "skincare with peptides for women 30+"), so the new hooks fit you.
3. Click **Start**. A run with 30 videos per source takes about 2-4 minutes.
4. Open **REPORT** in the Storage tab for the visual report, or the **Hooks** view of the dataset for the table.
5. Copy the templates and rewrites into your next scripts.

### How it works

1. Collects the videos on your Apify account: TikTok with subtitles (about US$0.0037 per video), Instagram Reels (about US$0.0026 per reel) or YouTube Shorts with subtitles (about US$0.004 per Short). Cap it with **Max spend on collecting videos**.
2. Downloads each video's subtitles and keeps the words spoken before second 3.
3. Classifies the hook with bilingual rules, then (optionally) refines it with AI.
4. Ranks hook types and lengths by median views, and writes the playbook and report.

### AI providers

AI insights work with the provider you already use. Add one key, or none to use the built-in AI.

| Provider | Key | Default model |
| --- | --- | --- |
| Anthropic | `anthropicApiKey` | `claude-opus-5-5` |
| OpenAI | `openaiApiKey` | `gpt-6.1-terra` |
| OpenRouter | `openrouterApiKey` | `anthropic/claude-sonnet-5.5` (any model id from openrouter.ai/models works) |
| Google Gemini | `geminiApiKey` | `gemini-3.6-flash` |
| xAI (Grok) | `xaiApiKey` | `grok-4.7` |
| DeepSeek | `deepseekApiKey` | `deepseek-v4-pro` |
| Mistral | `mistralApiKey` | `mistral-large-latest` |

With your own key, that provider bills you directly and the AI events below are not charged. Without any key, the AI insights are simply skipped and you still get the full rule-based analysis.

### Pricing

Pay per event, on top of collecting the videos:

| Event | Price | When |
| --- | --- | --- |
| `video-analyzed` | US$0.003 | Each video row in the results |
| `ai-video-insight` | US$0.02 | Each video with AI insights (built-in AI only) |
| `hook-playbook` | US$0.10 | The AI playbook, once per run (built-in AI only) |
| `on-screen-text` | US$0.005 | Each cover read with AI vision (built-in AI only, when *Read on-screen text* is on) |

**Examples:** 50 videos without AI cost US$0.15. 50 videos with the built-in AI cost US$0.15 + US$1.00 + US$0.10 = US$1.25. With your own AI key, the same run costs US$0.15 here plus what your provider bills (usually a few cents).

### FAQ

**Why are some videos missing?** Ads are skipped (turn on **Include ads** to keep them) and so are videos under **Minimum views**. The final status message says how many were skipped.

**Where does the hook come from?** From TikTok's own subtitles: the words spoken before second 3. Videos without subtitles use the first line of their caption (`hookSource: "caption"`), unless you turn on **Transcribe videos without subtitles**.

**Does it work in Spanish?** Yes. Hook types are detected in Spanish and English, and the report and AI insights can be in Spanish or English.

**Can I analyse Instagram Reels or YouTube Shorts?** Not yet; TikTok only for now.

### Tips

- 20-50 videos per source is enough to see patterns; more makes the medians steadier.
- Analyse 3-5 competitor profiles plus 1-2 hashtags for a niche-specific playbook.
- Turn on **Transcribe videos without subtitles** when your niche has many videos without captions.

### Development

```bash
python -m pytest tests -q                  # offline unit tests
python scripts/smoke_test.py ./tmp-smoke   # full run with a fake scraper and a fake AI
apify push                                 # deploy
```

Set `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` or `OPENROUTER_API_KEY` as a secret environment variable to offer the built-in AI.

# Actor input Schema

## `platform` (type: `string`):

TikTok and YouTube Shorts give the spoken hook from subtitles. Instagram gives the caption; turn on 'Read on-screen text' to also read the text on the first frame.

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

TikTok hashtags without the # (for example: skincare, rutinadeskincare).

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

TikTok searches. Results are sorted by most liked.

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

Competitor accounts: TikTok or Instagram usernames, or YouTube channel links / @handles. Their most popular videos are analysed.

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

Individual TikTok video links.

## `videosPerSource` (type: `integer`):

How many videos to collect from each source.

## `searchDateFilter` (type: `string`):

Only for search keywords: recent hooks reflect what works now.

## `minViews` (type: `integer`):

Skip videos below this many views, so only proven hooks are studied.

## `includeAds` (type: `boolean`):

Keep sponsored videos in the analysis.

## `transcribeMissing` (type: `boolean`):

TikTok only: videos with no subtitles get transcribed (a small extra data cost). Off: their caption text is used as the hook.

## `scraperMaxCostUsd` (type: `integer`):

Upper limit for collecting the videos on your account.

## `aiInsights` (type: `boolean`):

For each hook: why it works, a reusable template and 2 rewrites for your niche. Plus a playbook for the whole run.

## `readOnScreenText` (type: `boolean`):

AI reads the words written on each video's cover / first frame. When a video has no spoken hook, that text becomes the hook. Needs AI (built-in or your key).

## `yourNiche` (type: `string`):

Who you create for, so rewrites fit you. Example: 'skincare with peptides for women 30+'.

## `yourBrand` (type: `string`):

Brand name to use in the rewrites and hook ideas.

## `reportLanguage` (type: `string`):

Language of the AI insights and the HTML report.

## `aiMaxVideos` (type: `integer`):

AI insights go to the most viewed videos first.

## `aiProvider` (type: `string`):

Which AI writes the insights. Add the matching key below, or leave all keys empty to use the built-in AI (billed per AI event).

## `aiModel` (type: `string`):

Leave empty for the default: claude-opus-5-5 on Anthropic, gpt-6.1-terra on OpenAI, anthropic/claude-sonnet-5.5 on OpenRouter. On OpenRouter you can use any model id from openrouter.ai/models.

## `anthropicApiKey` (type: `string`):

Your own key from console.anthropic.com. With your own key (any provider), that provider bills you and AI events are not charged.

## `openaiApiKey` (type: `string`):

Your own key from platform.openai.com/api-keys.

## `openrouterApiKey` (type: `string`):

Your own key from openrouter.ai/keys. One key, hundreds of models.

## `geminiApiKey` (type: `string`):

Your own key from aistudio.google.com/apikey.

## `xaiApiKey` (type: `string`):

Your own key from console.x.ai.

## `deepseekApiKey` (type: `string`):

Your own key from platform.deepseek.com.

## `mistralApiKey` (type: `string`):

Your own key from console.mistral.ai.

## Actor input object example

```json
{
  "platform": "tiktok",
  "hashtags": [
    "skincare"
  ],
  "videosPerSource": 12,
  "searchDateFilter": "LAST_3_MONTHS",
  "minViews": 5000,
  "includeAds": false,
  "transcribeMissing": false,
  "scraperMaxCostUsd": 5,
  "aiInsights": true,
  "readOnScreenText": false,
  "reportLanguage": "es",
  "aiMaxVideos": 50,
  "aiProvider": "auto"
}
```

# Actor output Schema

## `report` (type: `string`):

No description

## `hooks` (type: `string`):

No description

## `summary` (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 = {
    "hashtags": [
        "skincare"
    ],
    "videosPerSource": 12,
    "minViews": 5000
};

// Run the Actor and wait for it to finish
const run = await client.actor("ingeniela/tiktok-viral-hook-analyzer").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": ["skincare"],
    "videosPerSource": 12,
    "minViews": 5000,
}

# Run the Actor and wait for it to finish
run = client.actor("ingeniela/tiktok-viral-hook-analyzer").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 '{
  "hashtags": [
    "skincare"
  ],
  "videosPerSource": 12,
  "minViews": 5000
}' |
apify call ingeniela/tiktok-viral-hook-analyzer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ingeniela/tiktok-viral-hook-analyzer"
        }
    }
}
```

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/bhXefGkqqz5LvVIWx/builds/mofVJPEGirdNUlxZS/openapi.json
