# YouTube Scraper | Extract Video Data & Search Results (`scrapie/youtube-scraper-extract-video-data-search-results`) Actor

Fast and reliable YouTube scraper to extract video metadata, search results, view counts, and comments. Automate YouTube data extraction without limits and export to JSON or CSV.

- **URL**: https://apify.com/scrapie/youtube-scraper-extract-video-data-search-results.md
- **Developed by:** [scrapie manchem](https://apify.com/scrapie) (community)
- **Categories:** Social media, SEO tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.005 / actor start

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## YouTube Scraper | Extract Video Data & Search Results [v1.0.1]

### What does YouTube Scraper do?

The YouTube Scraper is a powerful, automated tool designed to extract video data and search results directly from [YouTube](https://www.youtube.com). Instead of manually searching and copying data, this scraper automates the process and provides you with structured, clean data. 

It can extract comprehensive metadata including the video link, title, full description, views, likes, and comment counts. Built specifically for the Apify platform, it leverages Apify's robust proxy rotation and scheduling integrations to ensure your data extraction runs flawlessly, every time.

### Why use YouTube Scraper?

YouTube is the world's largest video platform and the second-largest search engine. Being able to extract and analyze its data programmatically gives you a massive advantage:
- **Market Research:** Monitor competitor channels and discover what content formats are getting the most engagement.
- **SEO & Keyword Tracking:** Analyze search results for specific keywords to see which videos rank at the top and track their metrics over time.
- **Trend Detection:** Quickly pull data on the most popular videos "This Month" or "This Week" to identify rising trends in any niche.
- **Lead Generation & Influencer Outreach:** Discover creators in your target industry based on their engagement rates.

### How to use YouTube Scraper

Using this scraper is incredibly simple and requires zero coding knowledge:

1. **Create a free Apify account:** If you haven't already, sign up on the Apify platform.
2. **Open the Actor:** Navigate to the YouTube Scraper actor page.
3. **Set your keywords:** Enter your desired search terms (e.g., "travel facts" or "tech reviews").
4. **Configure your filters (Optional):** Use the input options to filter by upload date, popularity, or duration.
5. **Run the scraper:** Click the "Start" button and wait for the run to complete.
6. **Export your data:** Once finished, download your data in JSON, CSV, Excel, XML, or HTML format.

### Input Configuration

The scraper accepts several parameters so you can precisely target the videos you want. Here is a breakdown of the input fields:

| Field | Type | Description | Example |
| ----- | ---- | ----------- | ------- |
| **Search Keywords** | Array | The keywords you want to search for on YouTube. | `["travel facts"]` |
| **Max Results** | Integer | The maximum number of videos to scrape per keyword. The scraper will scroll the page until it meets this limit. | `50` |
| **Type** | String | Filter the search by content type. | `Videos`, `Shorts`, `Channels`, `Playlists` |
| **Duration** | String | Filter videos based on their length. | `Under 4 minutes`, `Over 20 minutes` |
| **Upload Date** | String | Only extract videos uploaded within a certain timeframe. | `This week`, `This month`, `This year` |
| **Features** | String | Filter by features like Live, 4K, Subtitles, etc. | `4K`, `HD` |
| **Prioritize (Sort by)** | String | Choose how YouTube sorts the results. | `Popularity`, `Upload date`, `Rating` |

#### Sample Input JSON
```json
{
  "searchQueries": ["travel facts"],
  "maxResults": 10,
  "uploadDateFilter": "This month",
  "prioritizeFilter": "Popularity"
}
````

### Output Data

The scraper extracts the details of each matching video and saves it to a dataset. You can download this dataset in various formats such as JSON, HTML, CSV, or Excel.

#### Sample Output JSON

```json
{
  "url": "https://www.youtube.com/watch?v=14nwl_wV-Uo&pp=ygUMdHJhdmVsIGZhY3Rz",
  "keyword": "travel facts",
  "type": "Video",
  "title": "Time Travel Happened To Victor 1935 | Top 10 Unknown Facts | Ep94",
  "description": "Historical account of the alleged time traveler...more",
  "viewsText": "1.2M views  4 years ago",
  "likesText": "125K",
  "commentsCountText": "4,781 Comments"
}
```

#### Data Table

Here is a quick overview of the data fields extracted:

| Field | Description |
| ----- | ----------- |
| `url` | The direct link to the scraped YouTube Video or Short. |
| `keyword` | The search term that yielded this result. |
| `type` | Specifies whether the result is a standard `Video` or a `Short`. |
| `title` | The full title of the video. |
| `description` | The text description provided by the creator. |
| `viewsText` | How many views the video has alongside its age (e.g. "1.2M views  4 years ago"). |
| `likesText` | Total number of likes the video has received. |
| `commentsCountText` | Total amount of comments on the video. |

### Tips for Optimizing Runs

- **Be specific with filters:** Using filters like `Upload Date: This Week` and `Sort by: Popularity` severely cuts down on scrapable noise, helping your runs finish faster and cost less.
- **Experiment with Max Results:** Set a realistic `maxResults` limit. Scraping thousands of videos in a single run may trigger YouTube rate-limits. If you need massive bulk data, consider splitting your task across multiple runs with different keywords.

### FAQ & Disclaimers

**Is it legal to scrape YouTube?**
Scraping publicly available data is generally legal, provided you comply with copyright laws and do not extract personal, sensitive information. You are fully responsible for how you use the data. Please respect [YouTube's Terms of Service](https://www.youtube.com/t/terms) where applicable.

**Why did some fields return empty?**
Occasionally, YouTube disables comments or hides the like count for specific videos. When this happens, the scraper will simply return these fields as `null` and proceed.

**Need a custom solution or found a bug?**
If the structure of YouTube changes or you need custom data points extracted, feel free to report it in the `Issues` tab of the actor!

# Actor input Schema

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

List of keywords to search for

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

Maximum number of videos to scrape per keyword

## `typeFilter` (type: `string`):

Filter by Type (e.g., Videos, Shorts, Channels, Playlists, Movies). Leave empty for none.

## `durationFilter` (type: `string`):

Filter by Duration (e.g., Under 4 minutes, 4 - 20 minutes, Over 20 minutes). Leave empty for none.

## `uploadDateFilter` (type: `string`):

Filter by Upload Date (e.g., Today, This week, This month, This year). Leave empty for none.

## `featuresFilter` (type: `string`):

Filter by Features (e.g., Live, 4K, HD, Subtitles/CC). Leave empty for none.

## `prioritizeFilter` (type: `string`):

Sort by (e.g., Relevance, Popularity, Upload date, Rating)

## Actor input object example

```json
{
  "searchQueries": [
    "travel facts"
  ],
  "maxResults": 10,
  "typeFilter": "Videos",
  "durationFilter": "",
  "uploadDateFilter": "",
  "featuresFilter": "",
  "prioritizeFilter": "Popularity"
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapie/youtube-scraper-extract-video-data-search-results").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("scrapie/youtube-scraper-extract-video-data-search-results").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 '{}' |
apify call scrapie/youtube-scraper-extract-video-data-search-results --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "YouTube Scraper | Extract Video Data & Search Results",
        "description": "Fast and reliable YouTube scraper to extract video metadata, search results, view counts, and comments. Automate YouTube data extraction without limits and export to JSON or CSV.",
        "version": "0.0",
        "x-build-id": "VIG1G0BEk6sQv3sfh"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrapie~youtube-scraper-extract-video-data-search-results/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrapie-youtube-scraper-extract-video-data-search-results",
                "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/scrapie~youtube-scraper-extract-video-data-search-results/runs": {
            "post": {
                "operationId": "runs-sync-scrapie-youtube-scraper-extract-video-data-search-results",
                "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/scrapie~youtube-scraper-extract-video-data-search-results/run-sync": {
            "post": {
                "operationId": "run-sync-scrapie-youtube-scraper-extract-video-data-search-results",
                "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": [
                    "searchQueries"
                ],
                "properties": {
                    "searchQueries": {
                        "title": "Search Keywords",
                        "type": "array",
                        "description": "List of keywords to search for",
                        "default": [
                            "travel facts"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "type": "integer",
                        "description": "Maximum number of videos to scrape per keyword",
                        "default": 10
                    },
                    "typeFilter": {
                        "title": "Type",
                        "type": "string",
                        "description": "Filter by Type (e.g., Videos, Shorts, Channels, Playlists, Movies). Leave empty for none.",
                        "default": "Videos"
                    },
                    "durationFilter": {
                        "title": "Duration",
                        "type": "string",
                        "description": "Filter by Duration (e.g., Under 4 minutes, 4 - 20 minutes, Over 20 minutes). Leave empty for none.",
                        "default": ""
                    },
                    "uploadDateFilter": {
                        "title": "Upload Date",
                        "type": "string",
                        "description": "Filter by Upload Date (e.g., Today, This week, This month, This year). Leave empty for none.",
                        "default": ""
                    },
                    "featuresFilter": {
                        "title": "Features",
                        "type": "string",
                        "description": "Filter by Features (e.g., Live, 4K, HD, Subtitles/CC). Leave empty for none.",
                        "default": ""
                    },
                    "prioritizeFilter": {
                        "title": "Prioritize (Sort by)",
                        "type": "string",
                        "description": "Sort by (e.g., Relevance, Popularity, Upload date, Rating)",
                        "default": "Popularity"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
