# YouTube Scraper: videos, shorts, channels, comments & search (`pikoulas/youtube`) Actor

Scrape YouTube videos, Shorts, channels, playlists, search results and comments with replies: views, likes, publish dates, tags, subscribers, channel links. Sort channels and comments, filter search and by date. Fast, no browser, no API key.

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

## Pricing

from $1.00 / 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.

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 videos, Shorts, channels, playlists, search results and comments from YouTube:

- **Videos and Shorts:** any video by its URL or ID: watch, youtu.be, Shorts, embed and live links.
- **Channels:** by URL, @handle or channel ID. You get the channel's details and its videos, Shorts
  and live streams, newest, most popular or oldest first.
- **Search:** the videos or Shorts YouTube shows for a keyword, with its filters: upload date,
  duration, and features such as 4K, subtitles, Creative Commons or live.
- **Playlists:** every video of a playlist, in its order.
- **Comments:** as many as you need per video, top or newest first, with their replies if you want them.

Every video comes with its exact views and likes, publish date, duration, description, hashtags,
tags, category, comment count, live status, thumbnail, and its channel's name, handle, badge and
subscribers. Every channel comes with its subscribers, exact video and view counts, description,
links, country and join date. Every comment comes with its text, author, likes, reply count, date,
and whether it's pinned, hearted by the creator, or edited.

It needs no browser, no login and no API key. A video, 5 of a channel's, 5 from a search, the
channel and 55 comments took 13 seconds; a channel's 200 videos and 50 Shorts, a 50-video search
and a 100-video playlist, all with details, took 45 seconds to 2 minutes; 1,000 comments of one
video with their replies 15 seconds to 1.5 minutes, depending on how hard YouTube throttles the IP.
It costs **$1 per 1,000 videos** and **$0.30 per 1,000 comments**.

### What people use it for

- **Competitor and influencer research:** every upload of a channel with its views, likes and dates.
- **Content research:** what ranks for a keyword, which lengths and topics get the views.
- **Comment analysis:** audience sentiment, questions and feature requests, with the replies.
- **Monitoring:** new videos of a list of channels since a date, day by day.
- **Datasets for AI:** titles, descriptions, tags and comments at scale.

### How to scrape YouTube

1. Click **Try for free**; Apify's free plan covers a first run.
2. Enter **Videos and Shorts**, **Channels**, **Playlists** or **Search terms**, and how many videos you want.
3. Click **Start**, then download the results as JSON, CSV, Excel or HTML, or read them through
   the API.

An input with more options:

```json
{
  "videos": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ", "https://www.youtube.com/shorts/R6yNUnRXZ64"],
  "channels": ["@mkbhd", "https://www.youtube.com/@veritasium"],
  "maxVideosPerChannel": 100,
  "maxShortsPerChannel": 20,
  "channelSort": "newest",
  "searchTerms": ["sourdough bread"],
  "maxResultsPerSearch": 50,
  "uploadDate": "month",
  "playlists": ["https://www.youtube.com/playlist?list=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI"],
  "publishedAfter": "2026-09-01",
  "maxCommentsPerVideo": 100,
  "maxRepliesPerComment": 5
}
```

`maxCommentsPerVideo` counts replies too. Turn off `includeVideoDetails` for a faster run with what
channel tabs, playlists and search show: the title, rounded views, an approximate date and the
duration. Turn off `includeChannelDetails` to get a channel's videos only.

### Output

A video:

```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)",
  "channelName": "Rick Astley",
  "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
  "channelUrl": "https://www.youtube.com/channel/UCuAXFkgsw1L7xaCfnd5JJOw",
  "channelHandle": "@RickAstleyYT",
  "channelIsVerified": true,
  "subscribers": 4550000,
  "publishedAt": "2009-10-24T23:57:33-07:00",
  "durationSeconds": 213,
  "views": 1820558994,
  "likes": 19423981,
  "commentsCount": 2400000,
  "commentsOff": false,
  "description": "The official video for “Never Gonna Give You Up” by Rick Astley. ...",
  "hashtags": ["RickAstleyNever", "RickAstley", "NeverGonnaGiveYouUp", "WheneverYouNeedSomebody", "OfficialMusicVideo"],
  "keywords": ["rick astley", "Never Gonna Give You Up", "nggyu", "never gonna give you up lyrics", "rick rolled"],
  "category": "Music",
  "thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg",
  "isFamilySafe": true,
  "isUnlisted": false,
  "liveStatus": null,
  "liveStartedAt": null,
  "input": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "position": null
}
```

A channel:

```json
{
  "type": "channel",
  "id": "UCBJycsmduvYEL83R_U4JriQ",
  "url": "https://www.youtube.com/channel/UCBJycsmduvYEL83R_U4JriQ",
  "handle": "@mkbhd",
  "title": "Marques Brownlee",
  "description": "MKBHD: Quality Tech Videos | YouTuber | Geek | Consumer Electronics | Tech Head | Internet Personality!\n\nbusiness@MKBHD.com\n\nNYC",
  "subscribers": 21300000,
  "videos": 1853,
  "views": 5703905192,
  "joinedAt": "2008-03-21",
  "country": "United States",
  "isVerified": true,
  "links": [{"title": "Twitter", "url": "http://twitter.com/MKBHD"}, {"title": "Instagram", "url": "http://instagram.com/MKBHD"}],
  "keywords": "MKBHD MarquesBrownlee Marques Brownlee",
  "avatar": "https://yt3.googleusercontent.com/qu4TmIaYUlS41-dJ9gZ7DUR3nilvmB5_11i6OKSdvNnBNiyOusZP1bMN6ICnuxtjFBb6ioKgRQ=s900-c-k-c0x00ffffff-no-rj",
  "isFamilySafe": true,
  "input": "https://www.youtube.com/@mkbhd"
}
```

A comment:

```json
{
  "type": "comment",
  "id": "Ugzge340dBgB75hWBm54AaABAg",
  "videoId": "dQw4w9WgXcQ",
  "videoTitle": "Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)",
  "text": "can confirm: he never gave us up",
  "author": "@YouTube",
  "authorChannelId": "UCBR8-60-B28hp2BmDPdntcQ",
  "authorIsVerified": true,
  "authorIsChannelOwner": false,
  "likes": 320000,
  "replyCount": 963,
  "publishedAt": "2025-09-27",
  "publishedTimeText": "1 year ago",
  "isEdited": false,
  "isPinned": true,
  "isHearted": true,
  "isReply": false,
  "parentId": null
}
```

Shorts have `"type": "short"` and the same fields. A reply has `"isReply": true` and its comment's
ID as `parentId`.

### Use it as an API

One call runs it and returns the results as JSON (for runs under 5 minutes; longer ones start a
run and read its dataset). Apify's Python and JavaScript clients, and its Make, Zapier and n8n
integrations, work the same way.

```bash
curl -X POST "https://api.apify.com/v2/acts/pikoulas~youtube/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"videos": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"], "channels": ["@mkbhd"], "maxVideosPerChannel": 5, "searchTerms": ["sourdough bread"], "maxResultsPerSearch": 5, "maxCommentsPerVideo": 5}'
```

AI agents can call it as a tool through Apify's MCP server: `https://mcp.apify.com?tools=pikoulas/youtube`.

### How much does it cost to scrape YouTube?

You pay **$0.001 per video or Short**, which is $1 per 1,000, **$0.001 per channel**, and
**$0.0003 per comment or reply**, which is $0.30 per 1,000. Runs that go through Apify's
residential proxy also pay its traffic, $0.0012 per 100 KB: a video with details is about 20 KB,
1,000 comments about 1.3 MB. There are no monthly fees.

### Good to know

- YouTube shows comment and channel dates only as "3 weeks ago" and rounds them down, so
  `publishedAt` of a comment is the latest date it can be. Likes of comments, subscribers and
  comment counts are rounded by YouTube too (320K, 21.3M).
- Without video details, dates of channel and playlist videos are approximate the same way, and
  Shorts from a channel's tab have no date at all. `publishedAfter` still works exactly: the run
  fetches the date of every video that could be on either side of it.
- YouTube's search sorts by relevance or popularity only; it dropped sorting by upload date and by
  rating. Use `uploadDate` for recent results.
- Tags, category and the exact publish time come from YouTube's player. When YouTube asks the
  run's IP to sign in there and no other IP is available, videos still come with their title,
  exact views and likes, date, description and channel, but without those.
- Private, deleted and members-only videos can't be scraped; the log names them.

### FAQ

#### Is it legal to scrape YouTube?

It collects only what YouTube shows publicly, without logging in. Scraping public data is
generally legal, but personal data is protected by laws such as the GDPR and the CCPA, and
YouTube's terms may limit how you use what you collect. If you're unsure, ask a lawyer;
Apify's [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/) is a good start.

#### Something missing or not working?

Open an issue on the **Issues** tab with the input you used, or ask there for a field you need.

# Actor input Schema

## `videos` (type: `array`):

Video or Shorts URLs or IDs: watch, youtu.be, Shorts, embed and live links all work.

## `channels` (type: `array`):

Channel URLs, @handles or channel IDs (UC...). Gives the channel's details and its videos, Shorts and live streams, as set below.

## `maxVideosPerChannel` (type: `integer`):

Videos from each channel's Videos tab. 0 for none.

## `maxShortsPerChannel` (type: `integer`):

Shorts from each channel's Shorts tab. 0 for none.

## `maxStreamsPerChannel` (type: `integer`):

Past, current and upcoming streams from each channel's Live tab. 0 for none.

## `channelSort` (type: `string`):

The order the channel's tabs are read in: newest, most popular or oldest first.

## `includeChannelDetails` (type: `boolean`):

One item per channel: subscribers, video and view counts, description, links, country, join date.

## `playlists` (type: `array`):

Playlist URLs or IDs (PL...).

## `maxVideosPerPlaylist` (type: `integer`):

How many videos to take from each playlist.

## `searchTerms` (type: `array`):

Keywords searched on YouTube, results in YouTube's order.

## `maxResultsPerSearch` (type: `integer`):

How many videos or Shorts to take from each search.

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

Videos only, Shorts only, or both as YouTube mixes them.

## `searchSort` (type: `string`):

YouTube's two orders: relevance, or popularity (views).

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

Search filter on the upload date.

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

Search filter on the length.

## `features` (type: `array`):

Search filters: only results with all of these.

## `includeVideoDetails` (type: `boolean`):

Exact views, likes, publish date, description, tags, category, comment count and the channel's subscribers. Off: the title, rounded views, approximate date and duration channel tabs, playlists and search show, which is faster. Videos given by URL always get details.

## `publishedAfter` (type: `string`):

Only videos published on or after this date (YYYY-MM-DD). With channels sorted newest first, the run stops reading a tab once it gets past it.

## `maxCommentsPerVideo` (type: `integer`):

Comments per video, replies included. 0 for none.

## `commentsSort` (type: `string`):

Top comments first, or newest first.

## `maxRepliesPerComment` (type: `integer`):

Replies to take under each comment. 0 for none.

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

Not needed for most runs. When YouTube refuses the run's IP on Apify, the run switches to Apify's residential proxy by itself.

## Actor input object example

```json
{
  "videos": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "channels": [
    "@mkbhd"
  ],
  "maxVideosPerChannel": 20,
  "maxShortsPerChannel": 0,
  "maxStreamsPerChannel": 0,
  "channelSort": "newest",
  "includeChannelDetails": true,
  "maxVideosPerPlaylist": 100,
  "maxResultsPerSearch": 50,
  "searchType": "videos",
  "searchSort": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "includeVideoDetails": true,
  "maxCommentsPerVideo": 0,
  "commentsSort": "top",
  "maxRepliesPerComment": 0,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

No description

## `channels` (type: `string`):

No description

## `comments` (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 = {
    "videos": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
    ],
    "channels": [
        "@mkbhd"
    ],
    "maxVideosPerChannel": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("pikoulas/youtube").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 = {
    "videos": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
    "channels": ["@mkbhd"],
    "maxVideosPerChannel": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("pikoulas/youtube").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 '{
  "videos": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
  ],
  "channels": [
    "@mkbhd"
  ],
  "maxVideosPerChannel": 20
}' |
apify call pikoulas/youtube --silent --output-dataset

```

## MCP server setup

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

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/IFNE2D40KjcZcyjIs/builds/YYU1Qq9is10Qsvaaj/openapi.json
