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

YouTube Scraper Tool is advance tool for search YouTube video based on search keyword, channel URL, channel name and many more filter given

- **URL**: https://apify.com/bhansalisoft/youtube-scraper.md
- **Developed by:** [bhansalisoft](https://apify.com/bhansalisoft) (community)
- **Categories:** Automation, Lead generation, Social media
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 results

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

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#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

## YouTube Scraper Actor (no external APIs)

Scrape YouTube channels, playlists, videos, and search results using Playwright and YouTube’s own page data (DOM + `window.ytInitial*`). No YouTube Data API and no `youtube-transcript-api`.

### What’s new

- Channel info only mode: set `channelInfoOnly = true` to scrape only the channel’s “About” data for the URLs you provide (channel or video). The actor will not scrape any videos or run searches in this mode.
- Accepts:
  - Channel URLs (e.g., `https://www.youtube.com/@theleaderstalk`, `https://www.youtube.com/channel/UCC...`)
  - Video URLs (the actor resolves the channel from the video)
  - A single `@handle` in `searchTerms` (e.g., `["@theleaderstalk"]`)

Output in this mode (`type: "channel_info"`):

- channelName
- channelUrl (prefers handle URL when available)
- channelUsername (handle without the `@`)
- channelId
- description
- channelLocation
- joinedDate
- channelTotalVideos
- channelTotalViews (numeric) and channelTotalViewsFormatted (with commas)
- numberOfSubscribers (numeric) and subscriberCountText
- socialLinks (array of `{ title, url }`)
- avatarUrl
- isMonetized (best-effort)
- sourceUrl (the input you provided)

### Other capabilities

- Channel enrichment (when not in channel-only mode):
  - name, URL, ID, @handle, subscriber counts, total views, total videos, location, social links, avatar, description, joined date
- Video details:
  - title, URL, thumbnail, view count, likes (best-effort), comments count (best-effort)
  - release date (ISO), duration (seconds + HH:MM:SS), hashtags
  - optional subtitles scraped via the UI, optional comments
- Search with rich UI filters (applied via YouTube “Filters” menu):
  - sorting, date filter, type, duration
  - feature toggles: HD, Subtitles/CC, Creative Commons, 3D, Purchased, 4K, 360°, Location
- Per-term limits for search (videos/shorts/streams)

### Input

Key fields:

- `channelInfoOnly` (boolean): Only scrape channel About info for provided URLs. If true:
  - Provide one or more channel or video URLs in `startUrls`, or
  - Provide a single `@handle` in `searchTerms`; the actor will treat it as a channel.
- `startUrls`: URLs to process (channel, video, playlist, search results)
- `directUrls`: extra URLs to merge into `startUrls`
- `searchTerms`: terms to search (ignored when `channelInfoOnly` is true unless a single `@handle` is provided)
- Subtitles options: `downloadSubtitles`, `saveSubsToKVS`, `subtitlesLanguage`, `preferAutoGeneratedSubtitles`, `subtitlesFormat`
- Search filters (non-channelOnly): `searchSortOrder`, `searchDateFilter`, `searchVideoType`, `searchDuration`
- Features (non-channelOnly): `hd`, `subtitles_cc`, `creative_commons`, `three_d`, `purchased`, `four_k`, `three_sixty`, `location`
- Limits: `maxVideosPerTerm`, `maxShortsPerTerm`, `maxStreamsPerTerm`, `maxResults`, `maxComments`
- Filters for post-processing: `dateFilter`, `videoRegex`
- `proxyConfiguration`, `verboseLog`

#### Examples

Channel info only

```json
{
  "channelInfoOnly": true,
  "startUrls": [
    { "url": "https://www.youtube.com/@theleaderstalk" },
    { "url": "https://www.youtube.com/watch?v=zslTD2Mq00E" }
  ],
  "proxyConfiguration": { "useApifyProxy": true }
}
```

Channel + videos (not channel-only)

```json
{
  "startUrls": [{ "url": "https://www.youtube.com/@LofiGirl" }],
  "maxResults": 50,
  "proxyConfiguration": { "useApifyProxy": true }
}
```

Search with filters

```json
{
  "searchTerms": ["traveler", "ai trends 2025"],
  "maxVideosPerTerm": 15,
  "maxShortsPerTerm": 8,
  "maxStreamsPerTerm": 2,
  "searchSortOrder": "relevance",
  "searchDateFilter": "this_year",
  "searchVideoType": "video",
  "searchDuration": "any",
  "hd": true,
  "subtitles_cc": true,
  "downloadSubtitles": true,
  "fetchFullVideoDetails": true,
  "maxResults": 30,
  "proxyConfiguration": { "useApifyProxy": true }
}
```

To search for the keyword

```json
{
  "startUrls": [],
  "searchTerms": ["marketing"],
  "maxResults": 10,
  "maxVideosPerTerm": 10,
  "proxyConfiguration": { "useApifyProxy": false },
  "verboseLog": false
}
```

# Actor input Schema

## `channelInfoOnly` (type: `boolean`):

Only scrape channel About information for the provided URLs (channels or videos). Ignores search/video extraction.

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

Paste YouTube URLs: channel (/@handle or /channel/ID), video (/watch?v=...), playlist, or even search results.

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

Search terms for YouTube search results. If Channel info only is enabled and you provide a single item like '@theleaderstalk', it will be treated as a channel.

## `maxVideosPerTerm` (type: `integer`):

Maximum number of regular video results to collect per search term.

## `maxShortsPerTerm` (type: `integer`):

Maximum number of Shorts results to collect per search term.

## `maxStreamsPerTerm` (type: `integer`):

Maximum number of live stream results to collect per search term.

## `directUrls` (type: `array`):

Direct YouTube URLs to include (video, channel, playlist).

## `downloadSubtitles` (type: `boolean`):

Open the transcript panel and scrape subtitles (no external APIs).

## `searchVideoType` (type: `string`):

Filter results by type.

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

Maximum number of results per URL or per search term overall (upper cap).

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

Configure proxy usage for reliable scraping.

## Actor input object example

```json
{
  "channelInfoOnly": false,
  "maxVideosPerTerm": 10,
  "maxShortsPerTerm": 0,
  "maxStreamsPerTerm": 0,
  "downloadSubtitles": false,
  "searchVideoType": "any",
  "maxResults": 50,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# 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("bhansalisoft/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 = {}

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

```

## MCP server setup

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