# YouTube Search Scraper API (`api_harbor/youtube-search-scraper`) Actor

Search YouTube by keyword: title, URL, channel, views, duration, publish date, with date, duration and sort filters. $1 per 1,000 videos, pay-per-video, failed items never charged. No API key, no quota. Callable from any MCP client (Claude, Cursor, ChatGPT).

- **URL**: https://apify.com/api_harbor/youtube-search-scraper.md
- **Developed by:** [Api Harbor](https://apify.com/api_harbor) (community)
- **Categories:** Videos, Social media
- **Features:** Limited permissions
- **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 Search Scraper API

Search YouTube by keyword and get the video results as clean data: title, URL, channel, views, duration and publish date. Filter by upload date and duration, sort by relevance, date, views or rating. Built for AI agents and data pipelines, and callable from any MCP client (Claude, Cursor, ChatGPT). No YouTube API key, no quota. Export to JSON, CSV or Excel, or call it as a YouTube search API.

**Price promise:** $1.00 per 1,000 videos, pay-per-video. Failed items and `error` rows are never charged. No proxy fees, no YouTube API key, no Google Cloud quota.

### What does YouTube Search Scraper do?

Type a search query, like in the YouTube search bar. The Actor goes through the result pages and returns one item per video:

- Video ID and URL
- Title
- Channel name and channel ID
- View count, duration and relative publish date

### What you get back

| Field | Type | Description |
|---|---|---|
| `videoId` | string | YouTube video ID |
| `url` | string | Video URL |
| `title` | string | Video title |
| `channel` | string | Channel name |
| `channelId` | string | Channel ID |
| `views` | string | View count as shown by YouTube, e.g. `188,908 views` |
| `duration` | string | Duration, e.g. `4:53` |
| `published` | string | Relative publish date, e.g. `8mo ago` |
| `input` | string | Input that failed (error rows only) |
| `error` | string | Error message (error rows only, never charged) |

### Why this YouTube search API instead of the official one

- **No API key, no quota.** The YouTube Data API charges 100 quota units per search call. Here you just pay per video.
- **Pay only for what you get.** $1.00 per 1,000 videos. Error rows are never charged.
- **Filters built in.** Upload date (hour, today, week, month, year), duration (short, medium, long) and sort order.
- **Agent-ready.** Clean JSON, structured errors, usable as an MCP tool.

### Use cases for AI agents, research and marketing

- **AI agents and research assistants:** let Claude or ChatGPT search YouTube through MCP, then pass the videos to the transcript tool.
- **RAG dataset building:** collect video lists on a topic, then fetch transcripts or comments for embeddings and analysis.
- **Influencer and creator discovery:** find channels that talk about your niche.
- **Competitor and trend watch:** track what gets published on a topic every week.
- **SEO and content research:** see which titles rank for your keywords.

### How much does it cost?

| What | Price |
|---|---|
| Run start | $0.00005 per run |
| Video | $1.00 per 1,000 videos |
| Failed item (`error` row) | $0 |
| Proxies, API key | $0, included |

The Apify free plan includes $5 of monthly credit, enough for about 5,000 videos. Set a maximum cost per run in Apify Console and the run stops cleanly at that budget.

### How to scrape YouTube search results

1. Click **Try for free**.
2. Enter a search query and the maximum number of results. Add filters if needed.
3. Click **Start**, then download your data as JSON, CSV, Excel or HTML.

Next steps: get the text of each video with [YouTube Transcript Scraper](https://apify.com/api_harbor/youtube-transcript-scraper), or the audience reactions with [YouTube Comments Scraper](https://apify.com/api_harbor/youtube-comments-scraper).

### Input

```json
{
  "query": "web scraping tutorial",
  "maxResults": 50,
  "uploadDate": "year",
  "duration": "medium",
  "sortBy": "view_count"
}
```

### Output example

Real items from a test run:

```json
[
  {
    "videoId": "hHQlcnubuFI",
    "url": "https://www.youtube.com/watch?v=hHQlcnubuFI",
    "title": "Learn Web Scraping in 5 Minutes (NO PRIOR KNOWLEDGE)",
    "channel": "CodeHead",
    "channelId": "UCFVteOob_YXJHPaGTqlDV2Q",
    "views": "188,908 views",
    "duration": "4:53",
    "published": "8mo ago"
  },
  {
    "videoId": "HCV6nEACQo4",
    "url": "https://www.youtube.com/watch?v=HCV6nEACQo4",
    "title": "WEB SCRAPING PYTHON [TUTO PROGRAMMATION COMPLET] (DÉBUTANT À AVANCÉ)",
    "channel": "CodeAvecJonathan",
    "channelId": "UCnjZz4nv490fE4SzUacSbBA",
    "views": "120,097 views",
    "duration": "1:46:20",
    "published": "2y ago"
  }
]
```

### Use it from AI agents (MCP)

This Actor is available as a tool through the Apify MCP server, so Claude, Cursor, ChatGPT or any MCP client can call it directly.

- MCP server URL: `https://mcp.apify.com/?actors=api_harbor/youtube-search-scraper`
- Token: Apify Console > **Settings** > **Integrations** (your Apify API token)

**Claude Desktop** (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/?actors=api_harbor/youtube-search-scraper",
      "headers": { "Authorization": "Bearer <APIFY_TOKEN>" }
    }
  }
}
```

**Claude Code:**

```bash
claude mcp add --transport http apify "https://mcp.apify.com/?actors=api_harbor/youtube-search-scraper" --header "Authorization: Bearer <APIFY_TOKEN>"
```

**Cursor** (`.cursor/mcp.json`) or **VS Code** (`.vscode/mcp.json`, use `"servers"` instead of `"mcpServers"`):

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/?actors=api_harbor/youtube-search-scraper",
      "headers": { "Authorization": "Bearer <APIFY_TOKEN>" }
    }
  }
}
```

Example prompts:

- "Find the 20 most viewed YouTube videos about 'web scraping tutorial' from this year and rank the channels."
- "Search YouTube for 'Claude Code review' uploaded this week and list titles, channels and views in a table."
- "Find medium-length videos about RAG pipelines, then get the transcript of the top 3."

### Use it from Python (YouTube API alternative)

```bash
pip install apify-client
```

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("api_harbor/youtube-search-scraper").call(run_input={"query": "web scraping tutorial", "maxResults": 50, "sortBy": "view_count"})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    if item.get("error"):
        print("failed:", item.get("input"), item["error"])  # not charged
        continue
    print(item)
```

### Fast cache and structured errors

- **Cache:** identical inputs are served from cache, so repeated requests come back in seconds.
- **Structured errors:** an item that cannot be fetched is returned as a row with an `error` field (and the failed `input`). These rows are **never charged**, and your agent or pipeline can branch on them without parsing logs.

### FAQ

**Do I need to log in or have a YouTube API key?**
No. No login, no Google account, no API key. Nothing to configure.

**How many results can I get per query?**
As many as YouTube returns for the query, usually several hundred. Set `maxResults` to cap the run.

**Is it legal to scrape YouTube search results?**
The Actor reads public search results only. You are responsible for complying with your local laws and YouTube's terms for your use case.

**Is there a YouTube search API?**
Yes: this Actor is one. Call it through the Apify REST API (`POST https://api.apify.com/v2/acts/api_harbor~youtube-search-scraper/run-sync-get-dataset-items`), the Python or JavaScript client, or MCP. The official YouTube Data API does not cover this use case without quota limits.

**Can I use it from Python?**
Yes. See the Python example above with `apify-client`.

**Can I schedule runs?**
Yes. Create a schedule in Apify Console (for example a weekly watch on a keyword). Each run writes a new dataset you can export or send to a webhook.

**Does it work with Make, Zapier or n8n?**
Yes. Use the official Apify integrations for Make, Zapier and n8n, or call the REST API from any HTTP node.

**Can AI agents use it through MCP?**
Yes. Add `https://mcp.apify.com/?actors=api_harbor/youtube-search-scraper` to Claude Desktop, Claude Code, Cursor, VS Code or any MCP client with your Apify token. See the MCP section above.

**Something is missing or broken?**
Open an issue in the **Issues** tab.

### Related Actors

- [YouTube Transcript Scraper API](https://apify.com/api_harbor/youtube-transcript-scraper): full text and timestamped segments of any video.
- [YouTube Comments Scraper API](https://apify.com/api_harbor/youtube-comments-scraper): comments and replies with likes and authors.
- [Website to Markdown](https://apify.com/api_harbor/website-to-markdown): turn any website into clean Markdown for LLMs and RAG.

# Actor input Schema

## `query` (type: `string`):

Keywords, as typed in the YouTube search bar.

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

Maximum number of videos to return.

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

Only videos uploaded in this period.

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

Short: under 4 min. Medium: 4 to 20 min. Long: over 20 min.

## `sortBy` (type: `string`):

Result order.

## Actor input object example

```json
{
  "query": "web scraping tutorial",
  "maxResults": 50,
  "uploadDate": "all",
  "duration": "all",
  "sortBy": "relevance"
}
```

# 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 = {
    "query": "web scraping tutorial",
    "maxResults": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("api_harbor/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 = {
    "query": "web scraping tutorial",
    "maxResults": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("api_harbor/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 '{
  "query": "web scraping tutorial",
  "maxResults": 50
}' |
apify call api_harbor/youtube-search-scraper --silent --output-dataset

```

## MCP server setup

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