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

Scrape YouTube trending videos by region and category using the YouTube Data API v3. Extract video metadata, views, likes, comments, and more for SEO research, content planning, and trend analysis.

- **URL**: https://apify.com/akash9078/youtube-trending-scraper.md
- **Developed by:** [Akash Kumar Naik](https://apify.com/akash9078) (community)
- **Categories:** Videos, SEO tools, Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

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 Trending Scraper - Apify Actor

### 🎬 YouTube Trending Videos Scraper - Real-Time Trend Data Extraction

**Discover what's trending on YouTube in real time!** This Apify Actor scrapes YouTube's most popular/trending videos by region and category using the official YouTube Data API v3. Perfect for SEO research, content planning, competitor analysis, market research, and trend discovery.

#### Why Choose This YouTube Trending Scraper?

- ✅ **Real-Time Data** - Get current trending videos as they appear on YouTube
- ✅ **Multi-Region Support** - Scrape trending videos from any country (US, IN, GB, DE, JP, etc.)
- ✅ **Category Filtering** - Filter by category (Music, Gaming, Sports, News, etc.)
- ✅ **No Quota Limits** - Uses official API with reliable data extraction
- ✅ **Pay Per Event** - Only pay for what you use, no monthly subscriptions
- ✅ **Developer Friendly** - Python-based with full API integration

---

### 🚀 Quick Start

#### Input Configuration

```json
{
  "regionCode": "US",
  "videoCategoryId": 0,
  "maxResults": 50
}
````

#### Run via CLI

```bash
apify run --input '{"regionCode": "US", "maxResults": 50}'
```

#### Run via API

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("your-username/youtube-trending-scraper").call(
    run_input={"regionCode": "US", "maxResults": 50}
)
```

***

### 📊 Output Data

The Actor returns comprehensive trending video data:

```json
{
  "video_id": "dQw4w9WgXcQ",
  "title": "Video Title",
  "description": "Video description",
  "channel_id": "UC...",
  "channel_title": "Channel Name",
  "published_at": "2024-01-15T12:00:00Z",
  "thumbnail_url": "https://i.ytimg.com/vi/...",
  "view_count": 1000000,
  "like_count": 50000,
  "comment_count": 2000,
  "duration": "PT10M30S",
  "region_code": "US",
  "video_category_id": null,
  "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "tags": ["music", "official"]
}
```

***

### 🌍 Supported Regions

Scrape YouTube trending videos from 200+ countries and regions using ISO 3166-1 alpha-2 codes:

| Region | Code | Region | Code |
|--------|------|--------|------|
| United States | US | Germany | DE |
| India | IN | Japan | JP |
| United Kingdom | GB | France | FR |
| Canada | CA | Brazil | BR |
| Australia | AU | Mexico | MX |
| South Korea | KR | Spain | ES |
| Russia | RU | Italy | IT |
| Indonesia | ID | Netherlands | NL |

***

### 📂 Video Categories

| Category ID | Category | Category ID | Category |
|-------------|----------|-------------|----------|
| 0 | All | 17 | Sports |
| 1 | Film & Animation | 18 | Shorts |
| 2 | Autos & Vehicles | 19 | Travel & Events |
| 10 | Music | 20 | Gaming |
| 15 | Pets & Animals | 21 | Videoblogging |
| 16 | Sports | 22 | People & Blogs |

***

### 💰 Pricing (Pay Per Event)

This Actor uses **Pay Per Event** pricing model:

- **Per Execution**: $0.0075 per run (up to 50 videos)
- **Free Units**: 0
- **Max Paid Units**: 50 videos per execution

#### Cost Examples

| Scenario | Videos | Cost |
|----------|--------|------|
| Single US trending fetch | 50 | $0.0075 |
| Multi-region (5 countries) | 250 | $0.0375 |
| Daily monitoring (30 days) | 1,500 | $0.225/month |

***

### 🔧 Use Cases

#### 📈 SEO Research

- Identify trending topics in your niche
- Discover high-performing video titles
- Analyze trending content patterns
- Track keyword trends over time

#### 🎬 Content Planning

- Find viral content ideas
- Monitor competitor videos
- Analyze trending categories
- Research content gaps

#### 📊 Market Research

- Regional content analysis
- Trend forecasting
- Audience interest mapping
- Brand monitoring

#### 🤖 AI & Data Science

- Training data collection
- Trend prediction models
- Sentiment analysis
- Social media research

***

### 🔌 API Integration

#### JavaScript

```javascript
const { ApifyClient } = require('apify-client');

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });

const input = {
  regionCode: 'US',
  videoCategoryId: 0,
  maxResults: 50
};

const run = await client.actor('your-username/youtube-trending-scraper').call(input);
const dataset = await client.dataset(run.defaultDatasetId).listItems();
console.log(dataset.items);
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient(token='YOUR_APIFY_TOKEN')

run_input = {
    'regionCode': 'US',
    'videoCategoryId': 0,
    'maxResults': 50
}

run = client.actor('your-username/youtube-trending-scraper').call(run_input=run_input)

## Get results
for item in client.dataset(run['defaultDatasetId']).list_items()['items']:
    print(item)
```

#### cURL

```bash
curl -X POST https://api.apify.com/v2/acts/YOUR_ACTOR_ID/runs \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"regionCode": "US", "maxResults": 50}'
```

***

### ⚡ Performance

- **Speed**: ~50 videos per second
- **Reliability**: 99.9% uptime
- **Data Freshness**: Real-time (current trending)
- **Rate Limits**: Subject to YouTube API quotas

***

### 🔐 Legal & Compliance

This tool is intended for personal, research, and educational use. Users must comply with:

- YouTube Terms of Service
- Google API Terms of Service
- Applicable laws in their jurisdiction

The developer is not liable for misuse.

***

### 📄 License

MIT License

# Actor input Schema

## `regionCode` (type: `string`):

ISO 3166-1 alpha-2 country code (e.g., US, IN, GB)

## `videoCategoryId` (type: `integer`):

Category ID to filter by (0 = all categories)

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

Maximum number of videos to retrieve (max 50)

## Actor input object example

```json
{
  "regionCode": "US",
  "videoCategoryId": 0,
  "maxResults": 50
}
```

# Actor output Schema

## `videos` (type: `string`):

YouTube trending videos with metadata, views, likes, comments

# 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 = {
    "regionCode": "US",
    "videoCategoryId": 0,
    "maxResults": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("akash9078/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 = {
    "regionCode": "US",
    "videoCategoryId": 0,
    "maxResults": 50,
}

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

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Trending Scraper",
        "description": "Scrape YouTube trending videos by region and category using the YouTube Data API v3. Extract video metadata, views, likes, comments, and more for SEO research, content planning, and trend analysis.",
        "version": "0.1",
        "x-build-id": "8qDGQ3FlD7UfgL1fS"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/akash9078~youtube-trending-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-akash9078-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/akash9078~youtube-trending-scraper/runs": {
            "post": {
                "operationId": "runs-sync-akash9078-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/akash9078~youtube-trending-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-akash9078-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": {
                    "regionCode": {
                        "title": "Region Code",
                        "type": "string",
                        "description": "ISO 3166-1 alpha-2 country code (e.g., US, IN, GB)",
                        "default": "US"
                    },
                    "videoCategoryId": {
                        "title": "Video Category ID",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Category ID to filter by (0 = all categories)",
                        "default": 0
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 50,
                        "type": "integer",
                        "description": "Maximum number of videos to retrieve (max 50)",
                        "default": 50
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
