# YouTube Scraper — Videos, Channels, Shorts, Search & Comments (`innolabs/youtube-scraper`) Actor

YouTube scraper API: videos, Shorts, channels, playlists, search results and comments with views, likes, subscribers and dates. No API key, no login. JSON/CSV/Excel.

- **URL**: https://apify.com/innolabs/youtube-scraper.md
- **Developed by:** [Tristan Leroux](https://apify.com/innolabs) (community)
- **Categories:** Videos, Social media
- **Features:** Limited permissions
- **Stats:** 6 total users, 6 monthly users, 98.6% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.04 / 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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## YouTube Scraper

Scrape **YouTube videos, Shorts, channels, playlists, search results and comments**:
titles, views, likes, comment counts, duration, publish dates, descriptions, tags,
categories, thumbnails, live and Shorts flags, channel subscribers, total channel views,
video counts, country, joined date and channel links, plus comments and replies with
likes and authors. No YouTube API key, no Google account, no login. Export as JSON, CSV or
Excel, or pull the data through the API.

### What does YouTube Scraper do?

YouTube Scraper reads public YouTube pages the way a logged-out visitor sees them and
returns clean records:

- **Search** — type keywords like the YouTube search bar and get the results, page after
  page, with YouTube's own filters: result type (videos, Shorts, channels, playlists,
  movies), upload date (today, this week, month, year), duration (under 3 minutes,
  3–20 minutes, over 20 minutes), sort by relevance or popularity, and features such as
  Live, 4K, HD, subtitles, Creative Commons, 360°, VR180, HDR or location.
- **Channels** — paste a channel link, `@handle` or channel ID and get one channel record
  (subscribers, total views, video count, country, joined date, description, links,
  avatar, banner, verified badge) plus the channel's **Videos**, **Shorts** and/or
  **Live** tabs, sorted by latest, most popular or oldest.
- **Playlists** — paste a playlist link and get the playlist record (title, owner,
  video count, views, description) and its videos in playlist order.
- **Videos and Shorts** — paste watch, youtu.be or `/shorts/` links and get full video
  details: title, full description, views, likes, comment count, duration, exact publish
  time, channel with subscriber count, tags, hashtags, category, thumbnail, Shorts, live,
  upcoming and unlisted flags.
- **Comments** — collect the comments of every video (top comments or newest first),
  optionally with their replies: text, author, author channel, likes, reply count, posted
  time, pinned/edited flags and a direct link to the comment.
- **Full details for listings** — optionally open every video found by search, channel or
  playlist to add likes, comment count, exact date, full description, tags and category,
  at the same price per video.

One run can mix search queries, channels, playlists, videos and search result URLs.

### Use cases

- **Marketing and brand monitoring** — track which videos rank for your product,
  brand or campaign keywords, and how views and likes develop over time.
- **Competitor and channel research** — compare channels by subscribers, total views,
  upload rhythm and the performance of their latest or most popular videos.
- **Influencer marketing and lead generation** — find channels for a topic with their
  subscriber counts, country, joined date and the social and business links on their
  About page.
- **Content strategy** — find the most viewed videos and Shorts for a keyword this week
  or month, their length, titles, tags and hashtags.
- **Audience and sentiment analysis** — collect the comments and replies under your own
  or competitors' videos and feed them into sentiment analysis or topic clustering.
- **Data and AI teams** — build datasets of video metadata, descriptions and comments for
  classification, recommendation or trend detection.

### How much does it cost?

You pay only for the results you get (pay-per-event). Duplicates and items over your
`maxItems` limit are never charged.

| Event | What you pay for | Free plan | Paid plans (from) |
| --- | --- | --- | --- |
| `video` | One video or Short in the dataset (from search, a channel tab, a playlist or a video URL), with or without full details | $0.04 per 1,000 | $0.04 per 1,000 |
| `channel` | One channel record (channel URLs and channel search results) | $0.09 per 1,000 | $0.049 per 1,000 |
| `playlist` | One playlist record (playlist URLs and playlist search results) | $0.09 per 1,000 | $0.049 per 1,000 |
| `comment` | One comment or reply in the dataset | $0.22 per 1,000 | $0.18 per 1,000 |

"Paid plans (from)" is the Gold-and-above price; Bronze and Silver plans sit in between.
Apify also charges a tiny actor-start fee ($0.00005 per run). Full video details
(**Full video details for search, channel and playlist results**) cost nothing extra.
Channel and playlist records can be switched off with **Include channel and playlist
records**.

Worked examples (Free plan prices):

1. **Keyword research** — 10 keywords × 200 videos with full details = 2,000 videos:
   2,000 × $0.04 / 1,000 = **$0.08**.
2. **Channel audit with comments** — 5 channels × 100 latest videos + 5 channel records +
   50 comments for each video: 500 × $0.04 / 1,000 + 5 × $0.09 / 1,000 + 25,000 × $0.22 / 1,000 =
   $0.02 + $0.00045 + $5.50 = **$5.52**.

The Apify Free plan includes $5 monthly credit, enough for about 125,000 videos or 22,000
comments every month.

### How to use YouTube Scraper

In Apify Console:

1. Open YouTube Scraper and click **Try for free**.
2. Type **Search queries** and/or paste **Start URLs** (videos, Shorts, channels,
   playlists or search result pages). The form is prefilled with one keyword, one channel
   and one video.
3. Set **Max results per search, channel tab or playlist**. **Max items** caps the whole
   run.
4. Optionally pick **Search filters**, **Channel tabs** and order, switch on
   **Full video details**, and set **Max comments per video** (0 = no comments).
5. Click **Start**. The prefilled input (about 40 items) takes a few seconds; listings run
   at hundreds of videos per minute.
6. Open the **Output** tab (views for videos, channels, playlists and comments) and export
   the dataset as JSON, CSV, Excel or HTML.

Through the API:

1. Get your API token in Apify Console → Settings → Integrations.
2. Call the actor with your input JSON (see [Integrations and API](#integrations-and-api)).
3. Read the dataset items from the run.

### Input

Fill in `searchQueries`, `startUrls` or both.

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `searchQueries` | array | – | Keywords searched on YouTube. |
| `startUrls` | array | – | Videos (`watch?v=`, `youtu.be/`), Shorts (`/shorts/`), channels (`/@handle`, `/channel/UC…`, bare `@handle`; add `/shorts` or `/streams` for that tab), playlists (`/playlist?list=`) and search result pages (`/results?search_query=`). |
| `maxResultsPerSource` | integer | `50` | Results per search query, per channel tab and per playlist. |
| `searchType` | string | `video` | `video`, `shorts`, `channel`, `playlist`, `movie` or `all` (YouTube's mixed default). |
| `uploadDate` | string | `any` | `any`, `today`, `week`, `month`, `year`. |
| `duration` | string | `any` | `any`, `under3`, `3to20`, `over20` (minutes). |
| `searchSortBy` | string | `relevance` | `relevance` or `popularity` (most viewed). |
| `searchFeatures` | array | `[]` | Any of `live`, `4k`, `hd`, `subtitles`, `creativeCommons`, `360`, `vr180`, `3d`, `hdr`, `location`, `purchased`. |
| `channelTabs` | array | `["videos"]` | Channel tabs to read: `videos`, `shorts`, `streams` (Live). A tab in the URL wins. |
| `channelSortBy` | string | `latest` | `latest`, `popular` or `oldest`. |
| `includeChannelInfo` | boolean | `true` | One `channel` record per channel URL and one `playlist` record per playlist URL. |
| `fetchVideoDetails` | boolean | `false` | Full details for every video from search, channels and playlists. Video URLs always get full details. |
| `maxComments` | integer | `0` | Comments per video (replies included). `0` = no comments. |
| `commentsSortBy` | string | `top` | `top` or `newest`. |
| `includeReplies` | boolean | `false` | Also collect replies: each comment is followed by its replies (they count towards `maxComments`). |
| `maxItems` | integer | `1000` | Hard cap on all items in the run. |
| `proxyConfiguration` | object | Apify Proxy | Proxy settings. The default datacenter proxy works for YouTube. |
| `debug` | boolean | `false` | Log retries and every listing page. |

Example — the most viewed videos of the week for two keywords, with full details:

```json
{
    "searchQueries": ["iphone 17 review", "pixel 10 review"],
    "searchType": "video",
    "uploadDate": "week",
    "searchSortBy": "popularity",
    "maxResultsPerSource": 100,
    "fetchVideoDetails": true
}
```

Example — channels: about info, latest 50 videos and 50 Shorts each:

```json
{
    "startUrls": ["https://www.youtube.com/@MrBeast", "https://www.youtube.com/@mkbhd"],
    "channelTabs": ["videos", "shorts"],
    "maxResultsPerSource": 50
}
```

Example — 500 newest comments with replies for two videos:

```json
{
    "startUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ", "https://youtu.be/jNQXAC9IVRw"],
    "maxComments": 500,
    "commentsSortBy": "newest",
    "includeReplies": true
}
```

Example — find channels for a topic, with subscribers, country and links:

```json
{
    "searchQueries": ["home espresso"],
    "searchType": "channel",
    "maxResultsPerSource": 40
}
```

### Output

Every item has `type` (`video`, `channel`, `playlist` or `comment`), `source` (`search`,
`channel`, `playlist`, `video` or `comments`), `sourceInput` (the keyword or URL it came
from) and `scrapedAt`. Examples from real runs on 2026-11-07 (long text shortened).

#### Video (video URL, full details)

```json
{
    "type": "video",
    "id": "dQw4w9WgXcQ",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "title": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
    "description": "The official video for “Never Gonna Give You Up” by Rick Astley. …",
    "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
    "channelName": "Rick Astley",
    "channelHandle": "@RickAstleyYT",
    "channelUrl": "https://www.youtube.com/@RickAstleyYT",
    "isVerifiedChannel": true,
    "channelSubscriberCount": 4560000,
    "viewCount": 1834627811,
    "likeCount": 19494084,
    "commentCount": 2400000,
    "duration": "3:33",
    "durationSec": 213,
    "publishedAt": "2009-10-25T06:57:33Z",
    "publishedTimeText": "17 years ago",
    "isShort": false,
    "isLive": false,
    "isUpcoming": false,
    "wasLive": false,
    "scheduledStartAt": null,
    "tags": ["rick astley", "Never Gonna Give You Up", "nggyu", "…"],
    "hashtags": ["#OfficialMusicVideo", "#NeverGonnaGiveYouUp", "#RickAstleyNever"],
    "category": "Music",
    "isFamilySafe": true,
    "isUnlisted": false,
    "isMembersOnly": null,
    "badges": null,
    "thumbnailUrl": "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg",
    "detailsFetched": true,
    "source": "video",
    "sourceInput": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "searchQuery": null,
    "playlistId": null,
    "position": 1,
    "scrapedAt": "2026-11-07T12:02:38Z"
}
```

Videos from search, channel tabs and playlists have the same fields. Without full
details, the fields YouTube does not show in listings (`likeCount`, `commentCount`,
`publishedAt`, `tags`, `category`, full `description`) are `null` and `detailsFetched` is
`false`; `publishedTimeText` ("3 days ago") and `duration` are there. `position` is the
rank in the search results, channel tab or playlist.

#### Channel

```json
{
    "type": "channel",
    "id": "UCX6OQ3DkcsbYNE6H8uQQuVA",
    "url": "https://www.youtube.com/@MrBeast",
    "handle": "@MrBeast",
    "title": "MrBeast",
    "description": "SUBSCRIBE FOR A COOKIE! …",
    "subscriberCount": 525000000,
    "videoCount": 1012,
    "viewCount": 146075635838,
    "country": "United States",
    "joinedDate": "2012-02-19",
    "links": [
        {"title": "Follow", "url": "https://www.instagram.com/mrbeast/"},
        {"title": "Twitter", "url": "https://twitter.com/MrBeast"}
    ],
    "isVerified": true,
    "keywords": "mrbeast6000 beast mrbeast Mr.Beast mr",
    "isFamilySafe": true,
    "avatarUrl": "https://yt3.googleusercontent.com/…=s900-c-k-c0x00ffffff-no-rj",
    "bannerUrl": "https://yt3.googleusercontent.com/…=w2560-fcrop64=1,00005a57ffffa5a8-k-c0xffffffff-no-nd-rj",
    "rssUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UCX6OQ3DkcsbYNE6H8uQQuVA",
    "source": "channel",
    "sourceInput": "https://www.youtube.com/@MrBeast",
    "searchQuery": null,
    "position": null,
    "scrapedAt": "2026-11-07T12:10:40Z"
}
```

#### Playlist

```json
{
    "type": "playlist",
    "id": "PLObrtcm1Kw6PmbXg8bmfJN-o2Hgx8sidf",
    "url": "https://www.youtube.com/playlist?list=PLObrtcm1Kw6PmbXg8bmfJN-o2Hgx8sidf",
    "title": "Actor tutorials",
    "description": "Step-by-step tutorials for getting web data and automating workflows …",
    "channelId": "UCTgwcoeGGKmZ3zzCXN2qo_A",
    "channelName": "Apify",
    "channelHandle": "@Apify",
    "channelUrl": "https://www.youtube.com/@Apify",
    "videoCount": 108,
    "viewCount": 16405,
    "lastUpdatedText": null,
    "firstVideoId": "gYJvUcirJCU",
    "thumbnailUrl": "https://i.ytimg.com/vi/gYJvUcirJCU/hqdefault.jpg",
    "source": "playlist",
    "sourceInput": "https://www.youtube.com/playlist?list=PLObrtcm1Kw6PmbXg8bmfJN-o2Hgx8sidf"
}
```

#### Comment

```json
{
    "type": "comment",
    "id": "UgyyEqaBXOKgoi4cf7l4AaABAg",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ&lc=UgyyEqaBXOKgoi4cf7l4AaABAg",
    "videoId": "dQw4w9WgXcQ",
    "text": "Ok let’s be honest here\nRick rolling is the one meme that will never die",
    "authorName": "@JetpackGamer456",
    "authorChannelId": "UCNRtoaGfHCLksAz2ofEAfgA",
    "authorUrl": "https://www.youtube.com/@JetpackGamer456",
    "authorAvatarUrl": "https://yt3.ggpht.com/ytc/…=s88-c-k-c0x00ffffff-no-rj",
    "authorIsVerified": false,
    "authorIsChannelOwner": false,
    "likeCount": 428000,
    "replyCount": 768,
    "publishedTimeText": "6 years ago",
    "isEdited": true,
    "isPinned": false,
    "isHearted": false,
    "isReply": false,
    "parentId": null,
    "source": "comments",
    "sourceInput": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
```

Field notes:

- Counts are numbers. YouTube rounds some counts in listings ("1.4K views",
  "525M subscribers"); full details and channel About pages give exact view counts.
- `publishedAt` is the exact UTC publish time when YouTube serves it (full details), or
  the publish date (`YYYY-MM-DD`). Listings give `publishedTimeText` only.
- `isLive` is a stream that is live now; `isUpcoming` a scheduled stream or premiere
  (`scheduledStartAt`); `wasLive` a finished stream.
- Replies have `isReply: true` and `parentId` (the comment they answer).
- `channel` links are the real targets (unwrapped from YouTube's redirect).

### Integrations and API

Run the actor and get the items back in one call:

```bash
curl -X POST "https://api.apify.com/v2/acts/innolabs~youtube-scraper/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"searchQueries": ["web scraping"], "maxResultsPerSource": 50}'
```

Python with [apify-client](https://docs.apify.com/api/client/python):

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("innolabs/youtube-scraper").call(
    run_input={
        "startUrls": ["https://www.youtube.com/@mkbhd"],
        "channelTabs": ["videos"],
        "channelSortBy": "popular",
        "maxResultsPerSource": 100,
        "fetchVideoDetails": True,
    }
)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    if item["type"] == "video":
        print(item["viewCount"], item["likeCount"], item["title"])
```

- **Make, Zapier, n8n** — use the Apify app/node to start the actor and send videos or
  comments to Google Sheets, Airtable, Notion or Slack.
- **Scheduling** — create a schedule in Apify Console (e.g. every morning) to track a
  keyword or channels over time.
- **Webhooks** — trigger your pipeline when a run finishes.
- **AI agents (MCP)** — connect Claude, Cursor or other MCP clients through the Apify MCP
  server at https://mcp.apify.com and let your agent research YouTube on demand.

### FAQ

#### Is it legal to scrape YouTube?

The scraper only collects data YouTube shows publicly to any visitor without logging in:
public videos, channels, playlists and comments. It does not log in and cannot see
private or members-only content. Comments and channel pages contain names of people,
which may be personal data under laws such as GDPR, so make sure you have a legitimate
reason to store them and that your use complies with YouTube's terms.

#### Do I need a YouTube API key, Google account or proxies?

No. There is no API key, quota or login. The default Apify Proxy setting works; blocked
or rate-limited requests are retried automatically on fresh connections.

#### How many results can I get?

Channel tabs and playlists are paged to the end (thousands of videos per channel).
Search pages continue as long as YouTube returns new results, usually several hundred per
query; use filters and related keywords for more. Comments are paged until the video's
comment list ends or **Max comments per video** is reached. See [Limits](#limits).

#### Why are likes or tags empty for some videos?

Search, channel and playlist listings do not show likes, comment counts, tags or the
exact date. Switch on **Full video details for search, channel and playlist results** to
get them at the same price. Video URLs always get full details. Some videos hide their
like count; then `likeCount` is `null`.

#### What if a link fails?

Each search query and URL is processed on its own. If a video was removed, a channel
does not exist or a playlist is private, the run continues with the rest and the problem
is listed in the run log and the run's `SUMMARY` record. You are not charged for failed
inputs. If every input fails, the run is marked as failed with the reason.

#### Can I get the email address of a channel?

No. YouTube shows business email addresses only to signed-in users after a captcha, so
they are not in the data. The channel's About links (website, Instagram, X, TikTok and
others) and description are included.

#### Does it download videos or transcripts?

No, it collects metadata and comments. For transcripts and subtitles use a dedicated
YouTube transcript scraper.

### Limits

- YouTube rounds counts in listings: "1.4K views" becomes 1400 and "525M subscribers"
  525000000\. Full details give exact view and like counts; channel About pages give exact
  total views and video counts.
- Search results end when YouTube stops returning new results (typically a few hundred
  per query and filter combination).
- Comments: YouTube lists top-level comments and replies to logged-out visitors; held,
  hidden or deleted comments are not visible. Videos with comments turned off give no
  comment records.
- With full details on, a small share of videos may come without `tags` and `category`
  when YouTube withholds that data from every connection tried; all other fields are
  still filled.
- Private, members-only and age-restricted videos show only what YouTube shows logged-out
  visitors (often nothing); removed videos are reported as failed inputs.
- Channel business emails, video files, transcripts, dislike counts and analytics
  (watch time, revenue) are not available.

# Changelog

This Actor's version history is a separate document: https://apify.com/innolabs/youtube-scraper/changelog.md

# Actor input Schema

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

Keywords searched on YouTube, exactly like the search bar, e.g. 'web scraping' or 'iphone 17 review'. Use the search filters below to pick videos, Shorts, channels or playlists.

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

YouTube links: videos (watch?v=…, youtu.be/…), Shorts (/shorts/…), channels (https://www.youtube.com/@MrBeast, /channel/UC…, also a bare @handle; add /shorts or /streams to read that tab), playlists (/playlist?list=…) and search result pages (/results?search_query=…).

## `maxResultsPerSource` (type: `integer`):

How many results to take from each search query, each channel tab (videos, Shorts, live streams) and each playlist. YouTube pages are read until this number is reached or the list ends.

## `searchType` (type: `string`):

What to search for. 'All' returns what YouTube shows by default: videos plus Shorts shelves, channels and playlists.

## `uploadDate` (type: `string`):

Only results uploaded within this period.

## `duration` (type: `string`):

Only videos of this length.

## `searchSortBy` (type: `string`):

Relevance (YouTube's default) or Popularity (most viewed first). Combine Popularity with an upload date to get the most viewed recent videos.

## `searchFeatures` (type: `array`):

Only videos with all of these features.

## `channelTabs` (type: `array`):

Which tabs to read for each channel: Videos, Shorts and/or Live (past and upcoming streams). A tab named in the URL (e.g. https://www.youtube.com/@MrBeast/shorts) overrides this.

## `channelSortBy` (type: `string`):

Latest (newest first), Popular (most viewed first) or Oldest, like the chips on the channel page.

## `includeChannelInfo` (type: `boolean`):

For channel URLs also output one channel record (subscribers, total views, video count, country, joined date, links, description); for playlist URLs one playlist record (title, owner, video count, views).

## `fetchVideoDetails` (type: `boolean`):

Open every video found by search, channel or playlist to add likes, comment count, exact publish date, full description, tags, category and channel subscribers. Slower, same price. Video URLs always get full details.

## `maxComments` (type: `integer`):

Comments to collect for every video (from Start URLs and from search/channel/playlist results). 0 = no comments. With replies on, each comment is followed by its replies and they count towards this number.

## `commentsSortBy` (type: `string`):

Top comments (YouTube's default) or newest first.

## `includeReplies` (type: `boolean`):

Also collect the replies under each comment, right after the comment (marked isReply, with parentId).

## `maxItems` (type: `integer`):

Hard cap on dataset items (videos, channels, playlists and comments together). The run stops cleanly when reached.

## `proxyConfiguration` (type: `object`):

Apify Proxy settings. The default datacenter proxy works for YouTube; blocked requests are retried on new IPs automatically.

## `debug` (type: `boolean`):

Log retries and every listing page.

## Actor input object example

```json
{
  "searchQueries": [
    "web scraping"
  ],
  "startUrls": [
    "https://www.youtube.com/@MrBeast",
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxResultsPerSource": 10,
  "searchType": "video",
  "uploadDate": "any",
  "duration": "any",
  "searchSortBy": "relevance",
  "searchFeatures": [],
  "channelTabs": [
    "videos"
  ],
  "channelSortBy": "latest",
  "includeChannelInfo": true,
  "fetchVideoDetails": false,
  "maxComments": 3,
  "commentsSortBy": "top",
  "includeReplies": false,
  "maxItems": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "debug": false
}
```

# Actor output Schema

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

All items produced by the run, one JSON object per video, channel, playlist or comment.

# 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": [
        "web scraping"
    ],
    "startUrls": [
        "https://www.youtube.com/@MrBeast",
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ],
    "maxResultsPerSource": 10,
    "maxComments": 3,
    "maxItems": 100,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("innolabs/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": ["web scraping"],
    "startUrls": [
        "https://www.youtube.com/@MrBeast",
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    ],
    "maxResultsPerSource": 10,
    "maxComments": 3,
    "maxItems": 100,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("innolabs/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": [
    "web scraping"
  ],
  "startUrls": [
    "https://www.youtube.com/@MrBeast",
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "maxResultsPerSource": 10,
  "maxComments": 3,
  "maxItems": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call innolabs/youtube-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,innolabs/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/eqH6UhXKoiAAJUQiD/builds/KftuBj9jN6aZaOPcr/openapi.json
