# YouTube Trending Scraper (`crawlerbros/youtube-trending-scraper`) Actor

Scrape trending and popular YouTube videos by category. Returns ranked video lists for Gaming, News, Music, Movies, and more.

- **URL**: https://apify.com/crawlerbros/youtube-trending-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Videos, News, Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 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/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 Trending Scraper

Scrape trending and popular YouTube videos by category — Gaming, News, Music, Movies, and the main Trending feed. Returns ranked video lists with titles, channels, view counts, durations, thumbnails, and badge metadata.

### What You Get

Each scraped video includes:

| Field | Description | Example |
|-------|-------------|---------|
| `position` | Rank in the trending list | `1` |
| `videoId` | YouTube video ID | `"dQw4w9WgXcQ"` |
| `title` | Video title | `"Minecraft 1.21 Update"` |
| `channelName` | Channel display name | `"Dream"` |
| `channelUrl` | Full channel URL | `"https://www.youtube.com/@Dream"` |
| `viewCountText` | Human-readable view count | `"3.2M views"` |
| `publishedTimeText` | Relative publish time | `"2 days ago"` |
| `durationText` | Video duration | `"12:34"` |
| `thumbnailUrl` | Highest-resolution thumbnail URL | `"https://i.ytimg.com/vi/..."` |
| `badges` | Array of badge labels | `["4K", "CC"]` |
| `isLive` | Whether the video is a live stream | `true` |
| `category` | Input category used | `"gaming"` |
| `scrapedAt` | ISO 8601 UTC timestamp | `"2024-01-15T10:30:00+00:00"` |

> Fields with no value are omitted from output rather than being returned as null.

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `category` | string | `"gaming"` | Trending section: `now`, `gaming`, `music`, `movies`, `news` |
| `maxResults` | integer | `50` | Maximum number of videos to return (1–200) |
| `market` | string | `"US"` | Regional market: `US`, `GB`, `DE`, `IN`, `JP`, `BR`, `FR`, `ES`, `KR`, `RU` |

#### Category Notes

- **`gaming`** — YouTube Gaming trending feed. Works without authentication and typically surfaces dozens to hundreds of videos across shelf sections. Most reliable category.
- **`news`** — Redirects to the YouTube News channel and returns recent top-story videos grouped by shelf. Works without authentication. Typically surfaces 100–200 videos.
- **`music`** — YouTube Music channel. Returns music videos from trending playlists and charts. Works without authentication; surfaces 30–80 individual videos.
- **`movies`** — YouTube Movies channel. Requires YouTube authentication; unauthenticated access only shows a promotional page with no video data.
- **`now`** — Main YouTube Trending feed (`/feed/trending`). Requires YouTube authentication; unauthenticated requests redirect to the home page and return no results.

#### Example Input

```json
{
  "category": "gaming",
  "maxResults": 50,
  "market": "US"
}
````

### How It Works

The scraper uses Playwright (headless Chromium) to render YouTube's JavaScript-heavy trending pages and extract the embedded `ytInitialData` JSON object, which contains the full structured video data. HTTP-only fetches return 0 videos because trending pages require JS execution.

The scraper:

1. Launches a headless Chromium browser with consent cookies pre-set to bypass GDPR overlays
2. Navigates to the category URL with region parameters (`?gl=US&hl=en`)
3. Waits for JS to execute and populate `window.ytInitialData`
4. Parses shelf sections (`shelfRenderer`, `gridVideoRenderer`, `videoRenderer`, `richGridRenderer`) to extract all visible videos
5. Trims to `maxResults` and pushes to the dataset

### Frequently Asked Questions

**Why does the `now` or `movies` category return no results?**
YouTube's main trending feed (`/feed/trending`) and the Movies channel both require authentication. Unauthenticated users are silently redirected or shown only a promotional page with no video data. Use `gaming`, `news`, or `music` for reliable unauthenticated scraping.

**How many videos can I get?**
The Gaming category surfaces the most videos (200–400 across shelf sections). Music, Movies, and News categories depend on what YouTube populates on those channel pages, typically 30–100 videos. Set `maxResults` up to 200 to capture as many as possible.

**Does this work without a proxy?**
Yes. The scraper is designed to work without a proxy and actually tries without proxy first, as proxy IPs can trigger GDPR consent pages or regional redirects. A proxy is configured as a fallback if the initial no-proxy attempt fails.

**What regions are supported?**
US, GB, DE, IN, JP, BR, FR, ES, KR, RU. The `market` field sets the `gl` (geolocation) and `hl` (language) parameters to return region-specific trending content.

**Are live streams included?**
Yes. Live streams appear in trending feeds and are flagged with `"isLive": true` and a `"LIVE"` badge in the `badges` array.

**Why are some fields missing from certain videos?**
Fields like `publishedTimeText` and `durationText` are not available for live streams (they have no fixed duration or publish date yet). Fields with no value are omitted entirely from the output record to keep the data clean.

### Output Dataset Views

The dataset offers two views in the Apify UI:

- **Trending Overview** — Compact view: position, videoId, title, channelName, viewCountText, isLive, category
- **Full Details** — All fields including channelUrl, durationText, thumbnailUrl, badges, and scrapedAt timestamp

### Use Cases

- **Daily trend monitoring** — schedule the actor to run every morning and track which topics dominate the Gaming or Music trending feed
- **Content strategy** — identify which video formats, lengths, and titles are trending right now in your niche
- **Competitive intelligence** — see which channels are appearing in trending feeds across different categories
- **Market research** — compare trending content across different regional markets using the `market` parameter
- **News tracking** — use the `news` category to capture the day's top-story videos without a news API subscription
- **SEO and keyword research** — extract trending video titles to identify high-traffic keywords and phrases

### FAQ

**Which categories are most reliable?**
`gaming`, `news`, and `music` are the most reliable for unauthenticated scraping. `now` (main trending feed) and `movies` require YouTube authentication and return no results without it.

**How often does trending content change?**
The Gaming and Music trending lists refresh frequently throughout the day. For accurate trend snapshots, schedule runs every 1–6 hours.

**Can I scrape trending content for non-US markets?**
Yes. Set the `market` field to any supported country code (e.g. `GB`, `DE`, `JP`, `BR`). Results will reflect the trending content for that region.

**Do I need a proxy?**
No. The actor is designed to work without a proxy and tries direct connections first. Proxy fallback is used automatically when direct access is blocked.

**Why does `maxResults` sometimes return fewer videos than configured?**
YouTube's category pages have a fixed number of available trending slots. If a category has fewer videos than your `maxResults` limit, you will get all available videos.

### YouTube Scraper Suite

This actor is part of a complete YouTube data extraction toolkit. Explore the full suite:

| Actor | Description |
|-------|-------------|
| [YouTube Channel Scraper](https://apify.com/crawlerbros/youtube-channel-scraper) | Channel metadata, subscriber counts, and full video catalogs |
| [YouTube Channel Scraper Fast](https://apify.com/crawlerbros/youtube-channel-scraper-fast) | Streamlined channel scraper for high-volume and speed-sensitive workflows |
| [YouTube Comment Scraper](https://apify.com/crawlerbros/youtube-comment-scraper) | Comments, replies, likes, author info, and pinned/hearted status |
| [YouTube Email Scraper](https://apify.com/crawlerbros/youtube-email-scraper) | Creator contact emails from channel pages, Instagram, TikTok, and Linktree |
| [YouTube Hashtag Scraper](https://apify.com/crawlerbros/youtube-hashtag-scraper) | Videos and Shorts tagged with specific hashtags |
| [YouTube Playlist Scraper](https://apify.com/crawlerbros/youtube-playlist-scraper) | All videos and metadata from any YouTube playlist |
| [YouTube Search Scraper](https://apify.com/crawlerbros/youtube-search-scraper) | Search results including videos, channels, and playlists |
| [YouTube Shorts Scraper](https://apify.com/crawlerbros/youtube-shorts-scraper) | Shorts from channels or hashtags with full view and like metadata |
| [YouTube Transcript Scraper](https://apify.com/crawlerbros/youtube-transcript-scraper) | Timed transcripts and captions with optional Whisper AI fallback |
| [YouTube Trending Scraper](https://apify.com/crawlerbros/youtube-trending-scraper) | Ranked trending videos by category — Gaming, Music, News, Movies |
| [YouTube Video Details Scraper](https://apify.com/crawlerbros/youtube-video-details-scraper) | Comprehensive video metadata, chapters, endscreen, captions, and comments |
| [YouTube Video Downloader](https://apify.com/crawlerbros/youtube-video-downloader) | Download videos, playlists, and channels in any quality with metadata |

# Actor input Schema

## `category` (type: `string`):

Which YouTube trending section to scrape. 'Gaming', 'News', and 'Music' work without authentication. 'Now' (main trending feed) and 'Movies' require YouTube login and return no results for unauthenticated users.

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

Maximum number of trending videos to return. YouTube Gaming typically surfaces 200-400 videos across all shelf sections.

## `market` (type: `string`):

Country/region for localized trending results. Sets the gl URL parameter to target the correct regional trending feed.

## Actor input object example

```json
{
  "category": "gaming",
  "maxResults": 20,
  "market": "US"
}
```

# 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 = {
    "category": "gaming",
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/youtube-trending-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 = {
    "category": "gaming",
    "maxResults": 20,
}

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Trending Scraper",
        "description": "Scrape trending and popular YouTube videos by category. Returns ranked video lists for Gaming, News, Music, Movies, and more.",
        "version": "1.2",
        "x-build-id": "5ZCtgEnSeSoCtfTCD"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/crawlerbros~youtube-trending-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-crawlerbros-youtube-trending-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/crawlerbros~youtube-trending-scraper/runs": {
            "post": {
                "operationId": "runs-sync-crawlerbros-youtube-trending-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/crawlerbros~youtube-trending-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-crawlerbros-youtube-trending-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": {
                    "category": {
                        "title": "Category",
                        "enum": [
                            "now",
                            "gaming",
                            "music",
                            "movies",
                            "news"
                        ],
                        "type": "string",
                        "description": "Which YouTube trending section to scrape. 'Gaming', 'News', and 'Music' work without authentication. 'Now' (main trending feed) and 'Movies' require YouTube login and return no results for unauthenticated users.",
                        "default": "gaming"
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 200,
                        "type": "integer",
                        "description": "Maximum number of trending videos to return. YouTube Gaming typically surfaces 200-400 videos across all shelf sections.",
                        "default": 50
                    },
                    "market": {
                        "title": "Market / Region",
                        "enum": [
                            "US",
                            "GB",
                            "CA",
                            "AU",
                            "DE",
                            "FR",
                            "JP",
                            "KR",
                            "BR",
                            "IN",
                            "MX",
                            "IT",
                            "ES",
                            "NL",
                            "PL",
                            "RU",
                            "SE",
                            "NO",
                            "DK",
                            "FI",
                            "ZA",
                            "SG",
                            "HK",
                            "TW",
                            "ID",
                            "MY",
                            "TH",
                            "PH",
                            "AR",
                            "CO",
                            "CL"
                        ],
                        "type": "string",
                        "description": "Country/region for localized trending results. Sets the gl URL parameter to target the correct regional trending feed.",
                        "default": "US"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
