# YouTube Trend Scraper & Analyzer (`aiscraperdev/youtube-trend-scraper`) Actor

Search YouTube by keyword, region & sort order. Extracts deep Shorts metadata, subscriber counts, and auto-calculates a viral Trend Score (1–10).

- **URL**: https://apify.com/aiscraperdev/youtube-trend-scraper.md
- **Developed by:** [Randeep Dhillon](https://apify.com/aiscraperdev) (community)
- **Categories:** Automation, Videos, Developer tools
- **Stats:** 6 total users, 3 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $8.00 / 1,000 results

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/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

## YouTube Trend & Creator Scout — Trend Score, Shorts Deep Data

**Find viral content and hidden micro-influencers before they blow up — with mathematical scoring, not guesswork.**

Search YouTube by keyword, region, and sort order. Extracts deep metadata from both Videos and Shorts (including the data YouTube hides on the Shorts UI), then scores every result with a proprietary **Trend Rating** and **Creator Utility Flag** so you know instantly which content is outperforming and which creators are worth partnering with.

---

### Why This Scraper Is Different

Most YouTube scrapers dump raw numbers and leave the analysis to you.

This actor does the math **for you**.

Every result comes pre-scored using the **Views-to-Subscriber Ratio** — the same signal talent agencies and growth consultants use to identify breakout content before it saturates the market. No extra tools, no manual spreadsheet formulas. You get actionable intelligence directly in the output.

It also solves a well-known scraping pain point: **YouTube hides descriptions, upload dates, and subscriber counts on the Shorts feed**. This actor silently converts every Short into its standard video page during extraction to capture the deep metadata — then returns the correct `/shorts/` URL to you. You get the full picture with none of the missing fields.

---

### The Trend Rating System (1–10)

The **Trend Rating** is a mathematical score calculated from the Views-to-Subscriber Ratio of the video's channel.

````

Trend Ratio = Total Views ÷ Channel Subscriber Count

````

| Trend Rating | Ratio Threshold | What It Means |
|---|---|---|
| 🔥 **10** | Ratio ≥ 10× | Massively viral — views dwarf the audience size |
| ⚡ **9** | Ratio ≥ 5× | Exceptional outperformer |
| **8** | Ratio ≥ 2× | Strong viral signal |
| **7** | Ratio ≥ 1× | Solid outperformer |
| **6** | Ratio ≥ 0.5× | Above average |
| **5** | Ratio ≥ 0.2× | Standard performance |
| **4** | Ratio ≥ 0.1× | Below average reach |
| **2–3** | Ratio < 0.1× | Underperforming content |

#### Why This Metric Matters

A video with **5 million views** on a channel with **200K subscribers** is fundamentally different from the same video on a channel with **10 million subscribers**. The first is a viral breakout. The second is expected performance.

Raw view counts tell you what happened. The Trend Rating tells you **how surprising it was** — which is the signal that predicts future growth.

---

### The Creator Utility Flag

Every result is tagged with one of two values:

| Flag | Criteria | What It Signals |
|---|---|---|
| 🟢 **High Potential** | Trend Rating ≥ 7 | Content is outperforming the channel's baseline — creator is in a growth phase |
| ⚪ **Standard** | Trend Rating < 7 | Content performing at or below expected levels for channel size |

#### The Micro-Influencer Use Case

`High Potential` on a **small channel** is the most valuable signal in the dataset.

It means: a creator with a modest audience is producing content that spreads far beyond their follower base. These are the creators that influencer marketing agencies pay full-time scouts to find. This actor flags them automatically.

A creator with **180K subscribers** and **5.2M views** on a single Short is a `High Potential` flag. That same creator is currently affordable to sponsor. In 6 months, they may not be.

---

### Inputs

| Parameter | Type | Default | Description |
|---|---|---|---|
| `searchKeyword` | string | `"gym workout"` | Topic, niche, product, or creator category to search |
| `maxResults` | integer | `50` | Number of videos to extract (min: 5, max: 200) |
| `countryCode` | string | `"US"` | 2-letter ISO code to localise results (US, GB, IN, AU…) |
| `sortBy` | string | `"relevance"` | `relevance` · `date` · `viewCount` |
| `minTrendRating` | integer | `1` | Filter output to only return results at or above this score (1–10) |

---

### Output Schema

```json
{
  "videoId": "f5BFCmQZdhg",
  "platform": "YouTube Shorts",
  "title": "The Best Diet For Lean Muscle Mass",
  "description": "Quick breakdown of the optimal macros for lean muscle...",
  "thumbnailUrl": "https://i.ytimg.com/vi/f5BFCmQZdhg/hq720.jpg",
  "url": "https://www.youtube.com/shorts/f5BFCmQZdhg",
  "publishedAt": "2022-03-14",
  "playCount": 5700000,
  "likeCount": 142000,
  "commentCount": 890,
  "authorMeta": {
    "name": "Sadik Hadzovic",
    "channelUrl": "https://www.youtube.com/@SadikHadzovic1",
    "followers": 431000
  },
  "trendRating": 10,
  "creatorUtilityFlag": "High Potential"
}
````

#### Field Reference

| Field | Type | Notes |
|---|---|---|
| `videoId` | string | Unique YouTube video ID — use for deduplication across runs |
| `platform` | string | `YouTube Video` or `YouTube Shorts` |
| `title` | string | Full video title |
| `description` | string | Truncated description (first 300 chars) |
| `thumbnailUrl` | string | Direct `i.ytimg.com` CDN URL — no redirects |
| `url` | string | Clean video URL, stripped of tracking parameters |
| `publishedAt` | string | ISO date `YYYY-MM-DD` |
| `playCount` | integer | Total views at time of scrape |
| `likeCount` | integer | Total likes |
| `commentCount` | integer | Total comments |
| `authorMeta.name` | string | Channel display name |
| `authorMeta.channelUrl` | string | Direct channel URL |
| `authorMeta.followers` | integer | Subscriber count at time of scrape |
| `trendRating` | integer | Viral score 1–10 (Views ÷ Subscribers) |
| `creatorUtilityFlag` | string | `High Potential` or `Standard` |

***

### Sample Output

Keyword: `"gym diet plan"` · Country: `US` · Sort: `relevance`

```json
[
  {
    "videoId": "_IaUcV6v5q4",
    "trendRating": 10,
    "creatorUtilityFlag": "High Potential",
    "platform": "YouTube Shorts",
    "title": "High Protein Breakfast Options for Weight Loss & Muscle Gain",
    "playCount": 5200000,
    "likeCount": 18484,
    "commentCount": 99,
    "authorMeta": {
      "name": "Fit Food Doctor",
      "channelUrl": "https://www.youtube.com/@doctor0food",
      "followers": 183000
    },
    "publishedAt": "2024-10-14",
    "thumbnailUrl": "https://i.ytimg.com/vi/_IaUcV6v5q4/hq720.jpg",
    "url": "https://www.youtube.com/shorts/_IaUcV6v5q4"
  },
  {
    "videoId": "q7AFlWkncmg",
    "trendRating": 8,
    "creatorUtilityFlag": "High Potential",
    "platform": "YouTube Shorts",
    "title": "WHAT I EAT IN A DAY (Ep. 1) High Performance Diet",
    "playCount": 4800000,
    "likeCount": 132779,
    "commentCount": 1207,
    "authorMeta": {
      "name": "Adam Frater",
      "channelUrl": "https://www.youtube.com/@adam_frater",
      "followers": 1090000
    },
    "publishedAt": "2023-01-22",
    "thumbnailUrl": "https://i.ytimg.com/vi/q7AFlWkncmg/hq720.jpg",
    "url": "https://www.youtube.com/shorts/q7AFlWkncmg"
  }
]
```

***

### Who Is This For?

**Content Creators & YouTubers**
Search your niche keyword and sort by Trend Rating. You now have a ranked list of the exact content formats, thumbnail styles, and titles that are proven to outperform — not just popular, but *disproportionately* viral relative to channel size.

**Influencer Marketing Agencies**
Filter for `creatorUtilityFlag: "High Potential"` on channels under 500K subscribers. These are your micro-influencers mid-breakout. Budget: still affordable. Reach: growing fast.

**Social Media Strategists**
Compare Trend Ratings between `YouTube Video` and `YouTube Shorts` for the same keyword. Instantly know whether your target audience is consuming long-form or short-form content right now, in any region.

**SEO & Market Researchers**
Run the same keyword across multiple `countryCode` values. The Trend Score distribution tells you where a niche is saturated (scores clustering at 5–6) vs. where it's still wide open (scores polarised at 2 and 10).

***

### The Shorts Deep Data Fix

YouTube's Shorts feed omits key fields — no description, no exact date, no subscriber count. Most scrapers return these as empty or zero.

This actor detects every Short, silently fetches the full video page in the background, extracts the hidden metadata, then returns the clean `/shorts/` URL to you. You get the complete dataset on every result, regardless of format.

***

### Pricing

This actor uses **Pay Per Result** pricing.

| Event | Price |
|---|---|
| Per result extracted | $0.008 |
| Actor start | $0.05 |

50 results (default run) = **~$0.45**

***

### Input Schema Example

```json
{
  "searchKeyword": "gym diet plan",
  "maxResults": 50,
  "countryCode": "US",
  "sortBy": "relevance",
  "minTrendRating": 7
}
```

Setting `minTrendRating: 7` returns only `High Potential` and above — useful for focused influencer scouting runs where you only want the signal, not the noise.

***

### Limitations

- Results reflect YouTube's public search index at time of scrape. Subscriber counts and view counts are live at scrape time.
- Comment count extraction depends on page render state. Occasionally returns `0` on videos with comments disabled or heavy anti-scrape protection.
- YouTube's search index is personalised. Using `countryCode` input localises results but cannot fully replicate a signed-in user's feed.

***

### Support

Issues, feature requests, or custom data requirements — use the Apify actor issue tracker or contact via the store profile.

If this actor saves you time, a review on the store goes a long way. 🙏

# Actor input Schema

## `keyword` (type: `string`):

Enter the niche or topic (e.g., 'tech review', 'gym vlog')

## `maxResults` (type: `integer`):

Maximum number of trending posts to fetch

## `countryCode` (type: `string`):

2-letter ISO country code (e.g., US, IN, GB). Leave blank for default.

## `sortBy` (type: `string`):

Choose how you want the YouTube search results to be ordered.

## Actor input object example

```json
{
  "keyword": "gym workout",
  "maxResults": 20,
  "countryCode": "US",
  "sortBy": "relevance"
}
```

# Actor output Schema

## `results` (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 = {
    "keyword": "gym workout",
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("aiscraperdev/youtube-trend-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 = {
    "keyword": "gym workout",
    "maxResults": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("aiscraperdev/youtube-trend-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 '{
  "keyword": "gym workout",
  "maxResults": 20
}' |
apify call aiscraperdev/youtube-trend-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Trend Scraper & Analyzer",
        "description": "Search YouTube by keyword, region & sort order. Extracts deep Shorts metadata, subscriber counts, and auto-calculates a viral Trend Score (1–10).",
        "version": "0.0",
        "x-build-id": "BuxpB3neHJvNBBeOA"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/aiscraperdev~youtube-trend-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-aiscraperdev-youtube-trend-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/aiscraperdev~youtube-trend-scraper/runs": {
            "post": {
                "operationId": "runs-sync-aiscraperdev-youtube-trend-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/aiscraperdev~youtube-trend-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-aiscraperdev-youtube-trend-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",
                "required": [
                    "keyword"
                ],
                "properties": {
                    "keyword": {
                        "title": "Search Keyword",
                        "type": "string",
                        "description": "Enter the niche or topic (e.g., 'tech review', 'gym vlog')",
                        "default": "gym workout"
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 5,
                        "maximum": 200,
                        "type": "integer",
                        "description": "Maximum number of trending posts to fetch",
                        "default": 20
                    },
                    "countryCode": {
                        "title": "Country / Region",
                        "type": "string",
                        "description": "2-letter ISO country code (e.g., US, IN, GB). Leave blank for default.",
                        "default": "US"
                    },
                    "sortBy": {
                        "title": "Sort Results By",
                        "enum": [
                            "relevance",
                            "date",
                            "views"
                        ],
                        "type": "string",
                        "description": "Choose how you want the YouTube search results to be ordered.",
                        "default": "relevance"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
