# YouTube Scraper (`streamers/youtube-scraper`) Actor

YouTube crawler and video scraper. Alternative YouTube API with no limits or quotas. Extract and download channel name, likes, number of views, and number of subscribers.

- **URL**: https://apify.com/streamers/youtube-scraper.md
- **Developed by:** [Streamers](https://apify.com/streamers) (Apify)
- **Categories:** Videos, Social media
- **Stats:** 113,563 total users, 10,007 monthly users, 99.5% runs succeeded, 2,115 bookmarks
- **User rating**: 4.80 out of 5 stars

## Pricing

from $2.40 / 1,000 videos

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

### What does YouTube Scraper do?

YouTube Scraper extracts public data from YouTube pages, beyond what the [YouTube Data API](https://developers.google.com/youtube/v3) allows.

- Find **all kinds of data points** in bulk, from video titles to their description to the metadata associated with them
- Quickly **discover vital points** such as view count, number of comments, and snapshot the like counter
- Can also break down **playlists, streams, and search results**
- Export data in multiple formats: **JSON, CSV, Excel, or HTML**
- Export via SDKs (Python & Node.js), use **API Endpoints**, **webhooks**, or integrate with workflows

### Use cases for YouTube data

You can use this YouTube API to scrape data in order to:

- **[Monitor your brand on YouTube](https://apify.com/use-cases/youtube-brand-monitoring)**: [track YouTube mentions](https://blog.apify.com/youtube-brand-monitoring/) of your brand in video titles, descriptions, comments, and transcripts
- Use scraped profile data for **lead generation**, finding new opportunities your competitors haven't discovered yet
- Find **[YouTube trending topics](https://blog.apify.com/youtube-trending-topics/)** and **opinions** shared by content creators and commenting users
- **Analyze [YouTube competitors](https://apify.com/use-cases/youtube-competitor-analysis)**: get insights into [competitors' activity](https://blog.apify.com/ai-driven-youtube-growth-strategy/), comments, and engagement metrics
- **Identify harmful** or **illegal** content
- Scrape subtitles which can be fed to AI and used to make your own scripts
- Accumulate **information on products** and **services** from video reviews and automate your buying decisions
- **Filter** your **search results** based on more advanced criteria

### What data can you scrape from YouTube?

<table>
<tr>
<td>📺 Channel name</td>
<td>👍 Number of likes</td>
</tr>
<tr>
<td>📱 Social media links</td>
<td>💬 Comments count</td>
</tr>
<tr>
<td>📝 Video title</td>
<td>🔗 Video URL</td>
</tr>
<tr>
<td>🖍 Subtitles</td>
<td>📍 Channel location</td>
</tr>
<tr>
<td>📼 Total videos</td>
<td>🌐 Channel URL</td>
</tr>
<tr>
<td>👀 Number of views</td>
<td>👁️ Video view count</td>
</tr>
<tr>
<td>🧿 Total views</td>
<td>📈 Number of subscribers</td>
</tr>
<tr>
<td>⏱️ Duration</td>
<td>📅 Release date</td>
</tr>
<tr>
<td>#️⃣ Hashtags</td>
<td>📽️ Thumbnails</td>
</tr>
</table>

### How to scrape YouTube data

YouTube Scraper is designed with users in mind. This means anybody can get started in just minutes, even if they’ve never scraped data before.

1. [Create](https://console.apify.com/sign-up) a free Apify account using your email.
2. Open [YouTube Scraper.](https://apify.com/streamers/youtube-scraper)
3. Add one or more YouTube URLs or search terms
4. Click the “Start” button and wait for the data to be extracted.
5. Download your data in JSON, XML, CSV, Excel, or HTML.

For more information, watch our [short video tutorial](https://www.youtube.com/watch?v=RjHzznQy6hI).

https://www.youtube.com/watch?v=RjHzznQy6hI

### ⬇️ Input example

For input, you can either use the fields in Apify Console or enter it directly via JSON. You can also use this scraper locally — head over to the [input schema](https://apify.com/streamers/youtube-scraper/input-schema) tab for technical details.

You can scrape YouTube by search term or by direct URL and further refine your search by specifying whether you want to scrape full videos, shorts, or streams. You can also scrape subtitles from videos (this is done in a separate tab). Finally, it’s possible to also add filters and date ranges to searches.

<a href="https://console.apify.com/actors/h7sDV53CddomktSi5/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-scraper-input-options.png?raw=true" alt="YouTube Scraper input" style="width:70%;">
</a>

#### 🔗 How to scrape YouTube by URL or search term

1. Scraping **by URL 🔗** will get you data from any video, channel, playlist, or search results. You can add as many URLs as you want.
2. Scraping **by search term** 🔑 will get you data from YouTube search results. You can add as many search terms as you want.

<table>
<tr>
<td>Scraping by URL</td>
<td><p>Paste a YouTube link to a <a href="https://apify.com/[https://www.youtube.com/watch?v=RjHzznQy6hI](https://www.youtube.com/watch?v=RjHzznQy6hI)">YouTube video</a>, <a href="https://apify.com/[https://www.youtube.com/c/Apify](https://www.youtube.com/c/Apify)">channel</a>, <a href="https://apify.com/[https://www.youtube.com/playlist?list=PLObrtcm1Kw6PmbXg8bmfJN-o2Hgx8sidf](https://www.youtube.com/playlist?list=PLObrtcm1Kw6PmbXg8bmfJN-o2Hgx8sidf)">playlist</a>, or <a href="https://apify.com/[https://www.youtube.com/results?search_query=crawlee](https://www.youtube.com/results?search_query=crawlee)">search results page</a>. You can also import a CSV file or Google Sheet with a prepared list of URLs. Then choose how many results you would like to extract and click Start.</p>
</td>
</tr>
<tr>
<td>Scraping using search term</td>
<td>Type in keywords as you would normally do it in the YouTube search bar. Then choose how many results you would like to extract and click Start.</td>
</tr>
</table>

#### How to scrape YouTube shorts and streams

You determine the type of video you want to scrape through the main interface. In the fields that state the maximum number of each video type (regular videos, shorts, and streams), type 0 for each type you do *not* want to include. This also allows you to determine how many videos of each type to include in your search.

⚠️ Note that this filter only works when scraping by search term, *not* when scraping by URL.

<a href="https://console.apify.com/actors/h7sDV53CddomktSi5/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-scraper-input-video-types.png?raw=true" alt="YouTube Scraper video type" style="width:70%;">
</a>

#### How to filter YouTube videos by date

There are two ways to filter by date, depending on whether you’re scraping videos by URL or by search term.

**When scraping by search term**

To filter videos by date when using search terms, go to the “Add filters” section, and then under “Sorting order” choose “Upload date.”

Alternatively, you can also select videos published in the last hour, day, week, month, or year by selecting the appropriate option under the “Date filter” menu.

<a href="https://console.apify.com/actors/h7sDV53CddomktSi5/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-scraper-date-search-term.png?raw=true" alt="YouTube Scraper date filter by search term" style="width:70%;">
</a>

**When scraping by URL**

When scraping by URL, go to the input field that says “Date range (applicable only to scraping by channels URL).” There, type in (in absolute or relative numbers) by which date you want to filter the data and whether you want to sort the videos by newest, most popular, or oldest.

<a href="https://console.apify.com/actors/h7sDV53CddomktSi5/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-scraper-date-search-url.png?raw=true" alt="YouTube Scraper date filter by URL" style="width:70%;">
</a>

#### How to scrape YouTube transcript and subtitles

To get text for a video, use the **Transcription & subtitles** dropdown in the input. It has three options:

- **Only download subtitles (when present on the video)** – downloads the video's existing subtitles (the ones YouTube already provides). Subtitles are added to each dataset item under the `subtitles` field. Videos without subtitles get none.
- **Download subtitles + transcribe videos without subtitles ($)** – downloads existing subtitles when available, and for videos that have none, generates a transcript using speech-to-text AI. The generated transcript is stored in the key-value store and linked from the dataset item via `transcriptionUrl`.
- **Always transcribe ($)** – ignores any existing subtitles and always generates a transcript with speech-to-text AI, linked via `transcriptionUrl`.

Leave the dropdown empty to skip subtitles and transcription entirely.

<a href="https://console.apify.com/actors/h7sDV53CddomktSi5/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-scraper-subtitles.png?raw=true" alt="YouTube Scraper subtitles" style="width:70%;">
</a>

### ⬆️ Output example

The scraped results will be shown as a dataset which you can find in the **Storage** tab. Note that the output is organized as a table for viewing convenience, but it doesn’t show **all the fields**:

<a href="https://console.apify.com/actors/h7sDV53CddomktSi5/">
<img src="https://github.com/apify-projects/actor-readme-images/blob/master/youtube-scraper-output.png?raw=true" alt="YouTube Scraper output" style="width:100%;">
</a>

You can preview all the fields and **download the file with YouTube data in various formats** (JSON, CSV, Excel, and more). Here’s a few JSON examples of different YouTube scraping cases:

#### 💁‍♂️ Channel info

```json
{
  "id": "HV6OlMPn5sI",
  "title": "Raimu - The Spirit Within 🍃 [lofi hip hop/relaxing beats]",
  "duration": "29:54",
  "channelName": "Lofi Girl",
  "channelUrl": "<https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow>",
  "date": "10 months ago",
  "url": "<https://www.youtube.com/watch?v=HV6OlMPn5sI>",
  "viewCount": 410458,
  "fromYTUrl": "<https://www.youtube.com/@LofiGirl/videos>",
  "channelDescription": "\\"That girl studying by the window non-stop\\"\\n\\n🎧 | Listen on Spotify, Apple music and more\\n→   <https://bit.ly/lofigirl-playlists\\n\\n💬> | Join the Lofi Girl community \\n→   <https://bit.ly/lofigirl-discord\\n→>   <https://bit.ly/lofigirl-reddit\\n\\n🌎> | Lofi Girl on all social media\\n→   <https://bit.ly/lofigirl-sociaI>",
  "channelDescriptionLinks": [
    {
        "text": "Discord",
        "url": "<https://discord.com/invite/hUKvJnw>"
    },

  ],
  "channelJoinedDate": "Mar 18, 2015",
  "channelLocation": "France",
  "channelTotalVideos": 409,
  "channelTotalViews": "1,710,167,563",
  "numberOfSubscribers": 13100000,
  "isMonetized": true,
  "inputChannelUrl": "<https://www.youtube.com/@LofiGirl/about>"
}

```

#### 📹 A single video

```json
{
  "title": "Stromae - Santé (Live From The Tonight Show Starring Jimmy Fallon)",
  "id": "CW7gfrTlr0Y",
  "url": "<https://www.youtube.com/watch?v=CW7gfrTlr0Y>",
  "thumbnailUrl": "<https://i.ytimg.com/vi/CW7gfrTlr0Y/maxresdefault.jpg>",
  "viewCount": 35582192,
  "date": "2021-12-21",
  "likes": 512238,
  "location": null,
  "channelName": "StromaeVEVO",
  "channelUrl": "<http://www.youtube.com/@StromaeVEVO>",
  "numberOfSubscribers": 6930000,
  "duration": "00:03:17",
  "commentsCount": 14,
  "text": "Stromae - Santé (Live From The Tonight Show Starring Jimmy Fallon on NBC)\\nListen to \\"La solassitude\\" here: <https://stromae.lnk.to/la-solassitude\\nOrder> my new album \\"Multitude\\" here: <https://stromae.lnk.to/multitudeID\\n--\\nhttps://www.stromae.com/fr/\\nhttps://www.tiktok.com/@stromae\\nhttps://www.facebook.com/stromae\\nhttps://www.instagram.com/stromae\\nhttps://twitter.com/stromae\\n> ",
  "descriptionLinks": [
    {
      "url": "<https://stromae.lnk.to/la-solassitude>",
      "text": "<https://stromae.lnk.to/la-solassitude>"
    },

  ],
  "subtitles": null,
  "comments": null,
  "isMonetized": true,
  "commentsTurnedOff": false
}

```

#### 🎧 YouTube playlist

```json
{
  "id": "CdgDLaxe2Q4",
  "title": "Lecture 4 | String Theory and M-Theory",
  "duration": "1:23:37",
  "channelName": "Stanford",
  "channelUrl": "<https://www.youtube.com/@stanford>",
  "date": "12 years ago",
  "url": "<https://www.youtube.com/watch?v=CdgDLaxe2Q4&list=PL6i60qoDQhQGaGbbg-4aSwXJvxOqO6o5e&index=100>",
  "viewCount": 106000,
  "fromYTUrl": "<https://www.youtube.com/playlist?list=PL6i60qoDQhQGaGbbg-4aSwXJvxOqO6o5e>"
},

```

#### 🔎 YouTube search results

```json
{
  "id": "CwRMBKk8St0",
  "title": "LET'S ARGUE: Beyoncé Fails the Bechdel Test!",
  "duration": "13:48",
  "channelName": "fantano",
  "channelUrl": "<https://www.youtube.com/@fantano>",
  "date": "5 years ago",
  "url": "<https://www.youtube.com/watch?v=CwRMBKk8St0>",
  "viewCount": 635379,
  "fromYTUrl": "<https://www.youtube.com/results?search_query=bechdel+test>"
},

```

#### YouTube subtitles

```json
"subtitles": [
      {
        "srtUrl": "https://api.apify.com/v2/key-value-stores/WBeaA5MIHCBAR79Jy/records/subtitles_YmVqWiFEohY_en_auto_generated",
        "type": "auto_generated",
        "language": "en",
        "srt": "1\n00:00:0,320 --> 00:00:4,960\nEver feel like you've been chasing the\n\n2\n00:00:1,990 --> 00:00:4,960\n \n\n3\n00:00:2,000 --> 00:00:6,960\nwrong AI path? Look, I get it. I wasted\n\n4\n00:00:4,950 --> 00:00:6,960\n \n\n5\n00:00:4,960 --> 00:00:9,440\nmonths jumping from one trend to the\n\n6\n00:00:6,950 --> 00:00:9,440\n \n\n7\n00:00:6,960 --> 00:00:11,440\nnext, following outdated advice that\n\n8\n00:00:9,430 --> 00:00:11,440\n \n\n9\n00:00:9,440 --> 00:00:14,719\npromised quick results, but only left me\n\n10\n00:00:11,430 --> 00:00:14,719\n \n\n11\n00:00:11,440 --> 00:00:16,320\nstuck. In 2025, AI isn't about just\n\n12\n00:00:14,709 --> 00:00:16,320\n \n\n13\n00:00:14,719 --> 00:00:18,000\nlearning the basics. It's about\n\n14\n00:00:16,310 --> 00:00:18,000\n \n\n15\n00:00:16,320 --> 00:00:20,000\nmastering the skills companies are\n\n16\n00:00:17,990 --> 00:00:20,000\n \n\n17\n00:00:18,000 --> 00:00:22,240\ncrying out for right now. If I had to\n\n18\n00:00:19,990 --> 00:00:22,240\n \n\n19\n00:00:20,000 --> 00:00:24,960\nstart my AI journey over, I'd do it\n\n20\n00:00:22,230 --> 00:00:24,960\n \n\n21\n00:00:22,240 --> 00:00:26,640\ndifferently. I'd skip the fluff and dive\n\n22\n00:00:24,950 --> 00:00:26,640\n \n\n23\n00:00:24,960 --> 00:00:28,640\nstraight into what works in today's\n\n24\n00:00:26,630 --> 00:00:28,640\n \n\n25\n00:00:26,640 --> 00:00:31,480\nworld. And in this video, I'm sharing\n\n26\n00:00:28,630 --> 00:00:31,480\n \n\n27\n00:00:28,640 --> 00:00:34,239\nexactly how I'd learn AI from scratch in\n\n28\n00:00:31,470 --> 00:00:34,239\n \n\n29\n00:00:31,480 --> 00:00:36,160\n2025. No gimmicks, just actionable\n\"
      }
    ]
```

### Need to scrape YouTube comments or Shorts?

If you want to extract specific YouTube data, you can use one of the specialized scrapers below:

- 💬 [YouTube Comments Scraper](https://apify.com/streamers/youtube-comments-scraper)
- 🏎 [Fast YouTube Channel Scraper](https://apify.com/streamers/youtube-channel-scraper)
- ▶️ [YouTube Shorts Scraper](https://apify.com/streamers/youtube-shorts-scraper)
- 📽️ [YouTube Video Scraper by Hashtag](https://apify.com/streamers/youtube-video-scraper-by-hashtag)
- 📹 [YouTube Video Downloader](https://apify.com/pocesar/download-youtube-video).

You can also combine YouTube data with that from other social networks. For example you can gather data with our other [social media scrapers](https://apify.com/store?category=SOCIAL_MEDIA):

- [TikTok scrapers](https://apify.com/clockworks)
- [Instagram scrapers](https://apify.com/store/categories?search=instagram\&managedBy=APIFY)
- [Facebook scrapers](https://apify.com/store/categories?search=facebook\&managedBy=APIFY)

You can also use AI agents to do multiple tasks at one. For example, our [Comments Analyzer Agent](https://apify.com/apify/comments-analyzer-agent) can perform sentiment analysis of YouTube videos, or you could try our [Influencer Discovery Agent](https://apify.com/apify/influencer-discovery-agent) for lead generation on TikTok videos.

### Error items

When the scraper cannot retrieve data for a given input — for example a video is unavailable or a channel does not exist — it pushes an **error item** to the dataset instead of silently skipping it. Normal output items are never affected; you can tell them apart by the presence of an `error` field.

#### Error item structure

```json
{
    "url": "https://www.youtube.com/@somechannel",
    "input": "somechannel",
    "error": "CHANNEL_DOES_NOT_EXIST",
    "note": "Channel does not exist"
}
```

#### Error codes reference

| `error`                      | Meaning                                                             |
| ---------------------------- | ------------------------------------------------------------------- |
| `CHANNEL_DOES_NOT_EXIST`     | Channel URL points to a channel that does not exist                 |
| `NOT_FOUND`                  | Page was not found                                                  |
| `VIDEO_UNAVAILABLE`          | Video is not available (deleted, region-blocked, etc.)              |
| `AGE_RESTRICTED`             | Channel is age-restricted and cannot be accessed without login      |
| `CHANNEL_HAS_NO_VIDEOS`      | Channel exists but has no uploaded videos                           |
| `CHANNEL_HAS_NO_LIVE_VIDEOS` | Channel exists but has no live videos                               |
| `CHANNEL_HAS_NO_SHORTS`      | Channel exists but has no Shorts                                    |
| `DATE_FILTER_TOO_STRICT`     | Videos exist but none match the active date filter                  |
| `NO_VIDEOS`                  | No videos found on the page                                         |
| `NO_RESULTS`                 | No results collected — check that video-type limits are set above 0 |
| `NO_VALID_START_URLS`        | All provided start URLs were invalid or malformed                   |
| `INVALID_INPUT`              | Actor failed due to bad configuration (run is also terminated)      |
| `NO_COMMENTS`                | No comments found for the video                                     |

***

### ❓FAQ

#### Can I scrape dislikes from YouTube videos?

No. Both `dislike` and `details` properties have been removed altogether from new versions. Dislikes are not public info so you cannot scrape them.

#### Can I scrape subtitles from YouTube videos?

Yes. You can scrape all publicly available data from YouTube using a web scraper, including subtitles. Using this scraping tool, you can extract both autogenerated and added subtitles in SRT, WEBVTT, XML, or plain text format.

#### How much will scraping YouTube cost you?

YouTube Scraper uses our price-per-result model. Currently, it costs $5.00 for 1,000 videos, giving you a price of $0.005 per result. For more information, visit the [pricing tab](https://apify.com/streamers/youtube-scraper/pricing).

#### How many videos can you scrape with YouTube Scraper?

YouTube Scraper **can extract up to 20,000 videos per URL**. However, you have to keep in mind that scraping [youtube.com](http://youtube.com/) has many variables to it and may cause the results to fluctuate case by case. There’s no one-size-fits-all-use-cases number. The maximum number of results may vary depending on the complexity of the input, location, and other factors.

Therefore, while we regularly run scraper tests to keep the benchmarks in check, the results may also fluctuate without our knowing. **The best way to know for sure for your particular use case is to do a test run yourself**

#### Can I integrate this YouTube scraper with other apps?

YouTube Scraper can be connected with almost any cloud service or web app thanks to [integrations](https://apify.com/integrations) on the Apify platform. These include [Make](https://docs.apify.com/platform/integrations/make), [Zapier](https://docs.apify.com/platform/integrations/zapier), [Slack](https://docs.apify.com/platform/integrations/slack), [Airbyte](https://docs.apify.com/platform/integrations/airbyte), [GitHub](https://docs.apify.com/platform/integrations/github), [Google Drive](https://docs.apify.com/platform/integrations/drive), and [plenty more](https://docs.apify.com/platform/integrations).

Alternatively, you can use [webhooks](https://docs.apify.com/platform/integrations/webhooks) to carry out an action whenever an event occurs, e.g. get a notification whenever YouTube Scraper successfully finishes a run, or initiate a new process, like ordering your data.

#### Can I use YouTube Scraper with the API?

The Apify API gives you programmatic access to the Apify platform. The API is organized around RESTful HTTP endpoints that enable you to manage, schedule, and run Apify actors. The API also lets you access any datasets, monitor actor performance, fetch results, create and update versions, and more.

To access the API using Node.js, use the `apify-client` NPM package. To access the API using Python, use the `apify-client` PyPI package.
Check out the <a href="https://apify.com/[https://docs.apify.com/api/v2](https://docs.apify.com/api/v2)"  target="_blank"> Apify API reference</a> docs for full details or click on the <a href="https://apify.com/[https://apify.com/streamers/youtube-scraper/api](https://apify.com/streamers/youtube-scraper/api)"  target="_blank"> API tab</a> for code examples.

#### Can I use YouTube Scraper through an MCP Server?

With Apify API, you can use almost any Actor in conjunction with an MCP server. You can connect to the MCP server using clients like ClaudeDesktop and LibreChat, or even build your own. Read all about how you can [set up Apify Actors with MCP](https://blog.apify.com/how-to-use-mcp/).

For YouTube Scraper, go to the [MCP tab](https://apify.com/streamers/youtube-scraper/api/mcp) and then go through the following steps:

1. Start a Server-Sent Events (SSE) session to receive a `sessionId`
2. Send API messages using that `sessionId` to trigger the scraper
3. The message starts the Amazon ASINs Scraper with the provided input
4. The response should be: `Accepted`

#### Should I use a proxy when scraping YouTube?

Just like with other social media-related actors, using a proxy is essential if you want your scraper to run properly. You can either use your own proxy or stick to the default [Apify Proxy](https://docs.apify.com/proxy) servers. Datacenter proxies are recommended for use with this Actor.

#### Is it legal to scrape data from YouTube?

Scraping YouTube is legal as long as you adhere to regulations concerning copyright and personal data.

Personal data is protected by GDPR ([EU Regulation 2016/679](https://eur-lex.europa.eu/eli/reg/2016/679/oj)), and by other regulations around the world. You should not scrape personal data unless you have a legitimate reason to do so. If you're unsure whether your reason is legitimate, please consult your lawyers. You can also read our blog post on the [legality of web scraping](https://blog.apify.com/is-web-scraping-legal/).

#### Your feedback

We're always working on improving the performance of our Actors. If you've got any technical feedback on YouTube Scraper, or simply found a bug, please create an issue on the Actor's [Issues tab](https://apify.com/streamers/youtube-scraper/issues/open).

# Actor input Schema

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

Enter search terms just like you would enter it in YouTube's search bar.

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

Limit the number of videos you want to crawl. If you scrape a channel, acts as a limit for regular videos.

## `maxResultsShorts` (type: `integer`):

Limit the number of Shorts videos you want to crawl.

## `maxResultStreams` (type: `integer`):

Limit the number of Stream videos you want to crawl.

## `startUrls` (type: `array`):

Enter a link to a <a href='https://www.youtube.com/watch?v=xObhZ0Ga7EQ' target='_blank' rel='noopener'>YouTube video</a>, <a href='https://www.youtube.com/c/Apify' target='_blank' rel='noopener'>channel</a>, <a href='https://www.youtube.com/playlist?list=PLObrtcm1Kw6PmbXg8bmfJN-o2Hgx8sidf' target='_blank' rel='noopener'>playlist</a>, <a href='https://www.youtube.com/hashtag/apify' target='_blank' rel='noopener'>hashtag</a> or <a href='https://www.youtube.com/results?search_query=crawlee' target='_blank' rel='noopener'>search results page</a>. You can also import a CSV file or Google Sheet with a list of URLs.<br><b>Note:</b> Input from <i>Search term</i> will be ignored when using this option. If you only want to scrape shorts/streams, set Maximum search results to 0, otherwise they represented number of regular videos requested

## `transcriptionAndSubtitle` (type: `string`):

Choose whether to download subtitles, transcribe the video using speech-to-text AI, or both. Leave empty to skip subtitles and transcription. Subtitles are added to the dataset items, while transcripts are stored in the key-value store

## `subtitlesLanguage` (type: `string`):

Language to download subtitles in.<br><b>Note:</b> a subtitle-downloading option must be selected in <i>Transcription & subtitles</i> for this to work.

## `subtitlesFormat` (type: `string`):

Select in what format you want to download subtitles

## `sortingOrder` (type: `string`):

Select Youtube sorting parameter for search

## `dateFilter` (type: `string`):

Select Youtube upload date filter for search

## `videoType` (type: `string`):

Select Youtube video type filter for search

## `lengthFilter` (type: `string`):

Select Youtube video length filter for search

## `isHD` (type: `boolean`):

Will apply the HD filter for search

## `hasSubtitles` (type: `boolean`):

Will apply the Subtitles/CC filter for search

## `hasCC` (type: `boolean`):

Will apply the Creative Commons filter for search

## `is3D` (type: `boolean`):

Will apply the 3D filter for search

## `isLive` (type: `boolean`):

Will apply the Live filter for search

## `isBought` (type: `boolean`):

Will apply the Purchased filter for search

## `is4K` (type: `boolean`):

Will apply the 4K filter for search

## `is360` (type: `boolean`):

Will apply the 360 degrees filter for search

## `hasLocation` (type: `boolean`):

Will apply the Location filter for search

## `isHDR` (type: `boolean`):

Will apply the HDR filter for search

## `isVR180` (type: `boolean`):

Will apply the VR180 filter for search

## `oldestPostDate` (type: `string`):

Only posts uploaded after or on this date will be scraped. Alternatively, specify how old the scraped videos should be in days. Putting <code>1 day</code> will get you only today's posts, <code>2 days</code> - yesterday's and today's, and so on. Note, that if you select this, sorting parameter will be auto-reset to NEWEST

## `sortVideosBy` (type: `string`):

Maps to the sorting buttons on the top of the channel's 'Videos', 'Shorts' and 'Live' pages.

## `aiVideoDescription` (type: `boolean`):

If enabled, uses AI to generate a time-segmented description of the video, covering both visual and audio content for each segment.

## `aiVideoSummary` (type: `boolean`):

If enabled, uses AI to generate a concise conceptual summary of the video covering both visual and audio content.

## `saveSubsToKVS` (type: `boolean`):

If set to true, the scraper will save the downloaded subtitles to the key-value store. Transcripts are always saved to the key-value store

## `preferAutoGeneratedSubtitles` (type: `boolean`):

If set to true, automatically generated subtitles are preferred to user subtitles.<b> Note:</b> a subtitle language must be selected and a subtitle-downloading option must be selected in <i>Transcription & subtitles</i> for this to work.

## Actor input object example

```json
{
  "searchQueries": [
    "web scraping tutorials"
  ],
  "maxResults": 10,
  "maxResultsShorts": 5,
  "maxResultStreams": 0,
  "startUrls": [
    {
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    }
  ],
  "transcriptionAndSubtitle": "NONE",
  "subtitlesLanguage": "en",
  "subtitlesFormat": "srt",
  "sortingOrder": "relevance",
  "dateFilter": "month",
  "videoType": "video",
  "lengthFilter": "between420",
  "oldestPostDate": "2024-01-01",
  "sortVideosBy": "NEWEST",
  "aiVideoDescription": false,
  "aiVideoSummary": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing scraped YouTube video information

# 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 = {
    "searchQueries": [
        "Crawlee"
    ],
    "maxResults": 10,
    "maxResultsShorts": 0,
    "maxResultStreams": 0
};

// Run the Actor and wait for it to finish
const run = await client.actor("streamers/youtube-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 = {
    "searchQueries": ["Crawlee"],
    "maxResults": 10,
    "maxResultsShorts": 0,
    "maxResultStreams": 0,
}

# Run the Actor and wait for it to finish
run = client.actor("streamers/youtube-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchQueries": [
    "Crawlee"
  ],
  "maxResults": 10,
  "maxResultsShorts": 0,
  "maxResultStreams": 0
}' |
apify call streamers/youtube-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,streamers/youtube-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/h7sDV53CddomktSi5/builds/r1E8P4yMAOUGFVjtI/openapi.json
