# Youtube Search Scraper (`captainhandsome/youtube-search-scraper`) Actor

SELECTORS\_JSON-driven extractor. Maintained autonomously by the fleet healer daemon.

- **URL**: https://apify.com/captainhandsome/youtube-search-scraper.md
- **Developed by:** [Joseph McRell](https://apify.com/captainhandsome) (community)
- **Categories:** Social media, SEO tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

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?

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 Search Scraper - Videos, Channels & Views

Search public YouTube videos by keyword and export structured titles, watch URLs, video IDs, channels, displayed views, publication age, duration, and thumbnail URLs. Run one query or a bounded batch without a YouTube Data API key.

### What data can I extract?

- Video title, ID, and canonical watch URL
- Channel name and channel URL when available
- Displayed view count and relative publication age
- Video duration and thumbnail URL

### Input example

```json
{
  "search_query": "small business marketing",
  "max_items": 25
}
```

Use `search_queries` for up to 25 keyword searches. `max_items` is a hard run-wide result ceiling.

### Output example

```json
{
  "title": "Small Business Marketing Strategy",
  "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  "video_id": "dQw4w9WgXcQ",
  "channel_name": "Example Channel",
  "channel_url": "https://www.youtube.com/@example",
  "views": "1.2M views",
  "published": "2 years ago",
  "duration": "12:34",
  "thumbnail_url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg"
}
```

### Common use cases

- Discover videos and channels for a keyword
- Research content, competitors, creators, and search-result coverage
- Build seed lists for media monitoring or later enrichment
- Give an AI agent current public YouTube search context

### Use with AI agents and MCP

Example agent intent:

> Find 50 public YouTube videos about warehouse automation and return title, URL, channel, views, publication age, and duration.

```json
{
  "search_query": "warehouse automation",
  "max_items": 50
}
```

The strict input and dataset schemas let Apify MCP clients inspect the callable contract before execution.

### Pricing and cost control

The suggested launch price is **$0.003 per result**. Output charges are approximately $0.30 for 100 videos or $3.00 for 1,000, plus any platform charges shown by Apify. The live Store pricing is authoritative. Use `max_items` to bound spend.

### Reliability

The Actor scrolls YouTube search results, deduplicates by video ID, validates required fields, and is enrolled in the fleet's selector monitoring and staged self-healing process.

### Limitations and responsible use

- Extracts public search-result metadata, not transcripts or comments.
- View counts and publication times are display strings, not normalized historical metrics.
- YouTube can vary results by locale, session, and upstream experiments.
- Use the data in accordance with applicable law and platform terms.

### FAQ

#### Does this Actor need a YouTube API key?

No.

#### Can I search multiple keywords?

Yes. Supply `search_queries`; duplicates are removed and `max_items` limits total output.

#### Does it download videos or audio?

No. It returns public search metadata and links only.

See [CHANGELOG.md](CHANGELOG.md) for maintained schema changes.

# Actor input Schema

## `search_query` (type: `string`):

Keyword or phrase to search for on YouTube.

## `search_queries` (type: `array`):

Optional list of YouTube searches. When supplied, these are run instead of search\_query.

## `max_items` (type: `integer`):

Hard maximum number of unique video records returned and billed across all queries.

## Actor input object example

```json
{
  "search_query": "small business marketing",
  "max_items": 25
}
```

# Actor output Schema

## `results` (type: `string`):

Extracted records, one object per row on the source page.

# 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 = {
    "search_query": "small business marketing"
};

// Run the Actor and wait for it to finish
const run = await client.actor("captainhandsome/youtube-search-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 = { "search_query": "small business marketing" }

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

```

## MCP server setup

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