# YouTube Search Scraper - Keywords & Hashtags with Filters (`amethys/youtube-search-scraper`) Actor

\[$1/1000] Search YouTube videos, channels and playlists by keyword with every official filter (date, length, HD, subtitles, live, country, language), with exact stats, comments and a summary per query. #hashtags work without a key.

- **URL**: https://apify.com/amethys/youtube-search-scraper.md
- **Developed by:** [Amethys](https://apify.com/amethys) (community)
- **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 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/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: keywords and #hashtags with every filter

Search YouTube the official way. Each result comes back with exact statistics, and each query gets a ready-made summary row.

- **Keyword search** uses the official **YouTube Data API v3** with **your own free key**. It supports every filter YouTube offers: upload date, length, HD, subtitles, live/upcoming/past streams, country, language, license, category and channel.
- **#hashtag search works without any key.** You get the hashtag's top videos, plus how many videos and channels use it.

#### Why you need your own key for keywords

YouTube's `robots.txt` closes its search results page (`/results`) to all crawlers. This actor respects that and searches through the official API instead. The API is reliable, returns exact data and won't break when YouTube redesigns its pages. Your key is stored encrypted and is used only for your runs.

##### Get a free key (about 2 minutes)

1. Open the [Google Cloud Console](https://console.cloud.google.com/) and create a project.
2. Go to **APIs & Services > Library**, find **YouTube Data API v3** and click **Enable**.
3. Go to **APIs & Services > Credentials > Create credentials > API key**, then copy the key into **Your YouTube Data API key**.

##### Quota: what a run costs your key

Every Google project gets **10,000 free units per day**.

| Action | Units |
|---|---|
| One search page (up to 50 results) | 100 |
| Full statistics for up to 50 videos, channels or playlists | 1 |
| Up to 100 comments of one video | 1 |
| Up to 100 extra replies of one comment | 1 |

For example, 50 results for each of 10 keywords, with full statistics, costs about 1,010 units, so you can run that about 9 times a day for free. The run log shows an estimate before searching. If your daily quota runs out, the actor stops cleanly and keeps every result collected so far.

#### What you get

**Videos:**

- Title, URL, description and links, tags and hashtags
- Exact views, likes and comments
- Duration, publish date and category ID
- Channel name and ID, and thumbnails in every size
- Definition, captions flag, license, embeddable, made-for-kids, topic categories and region restrictions
- Live status, plus scheduled, start and end times and live viewers
- Chapters
- `search_rank`, plus `search_source` to show where each result was found

**Channels:** subscriber count, total views, video count, country, joined date, handle, description, avatar, banner and topic categories.

**Playlists:** title, owner, video count, publish date and privacy.

**Optional extras:**

- **Comments with replies**: author, text, likes and date.
- **Video page details**: chapters, caption languages, the channel's verified badge and subscriber count, and related videos. These come from the public video page and cost no quota.

**Query summary** (one row per query):

- Estimated total matches
- Results saved, by type
- Total, average and median views, and average likes
- Top 10 channels, top tags and top hashtags
- Most-viewed and newest video
- The filters used and the quota units used
- For #hashtags, the hashtag's total video and channel counts

#### #hashtags without a key

Enter queries starting with `#` (like `#minecraft`). Without a key you get the videos YouTube shows on the hashtag page, usually 15–20, each with full statistics if you turn on **Open video pages**. With a key, the actor adds API search results for that hashtag until it reaches your result limit.

#### Input example

```json
{
  "queries": ["electric car review", "#asmr"],
  "youtubeApiKey": "AIza...",
  "searchTypes": ["video", "channel"],
  "maxResultsPerQuery": 100,
  "order": "viewCount",
  "publishedAfter": "2026-01-01",
  "regionCode": "US",
  "videoDuration": "medium",
  "videoDefinition": "high",
  "maxCommentsPerVideo": 20
}
```

#### Limits

- YouTube's search returns up to about 500 results per query. The `total_results_estimate` field is YouTube's own estimate, not an exact count.
- Filters such as video length, HD, subtitles and live are video-only. When you also ask for channels or playlists, the actor runs a separate search for those without the video filters.
- No transcripts. YouTube's `robots.txt` disallows the caption endpoint, and the API only gives captions to the video's owner.

#### Pricing

**$1 per 1,000 results.** Summary rows count as results. Comments are nested inside their video and don't count separately. Your YouTube API quota is free, since you use your own Google project.

For channels, playlists, shorts and live tabs by URL, use the companion **YouTube Scraper**.

# Actor input Schema

## `queries` (type: `array`):

One search per line. Keywords use the official YouTube Data API with your own key. #hashtags (e.g. #minecraft) also work without a key: you get the hashtag's top 20 videos plus its total video and channel counts.

## `youtubeApiKey` (type: `string`):

Required for keyword search, optional for #hashtags. Free: Google Cloud Console > APIs & Services > Library > enable 'YouTube Data API v3' > Credentials > Create API key. Each page of up to 50 search results costs 100 of your 10,000 free daily quota units. Stored encrypted.

## `searchTypes` (type: `array`):

Which result types to return: videos, channels and/or playlists.

## `maxResultsPerQuery` (type: `integer`):

YouTube returns up to ~500 results per search. 50 results = 100 quota units.

## `order` (type: `string`):

Sort order of the search results.

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

Only results published on or after this date (YYYY-MM-DD).

## `publishedBefore` (type: `string`):

Only results published on or before this date (YYYY-MM-DD).

## `regionCode` (type: `string`):

Two-letter country code to search as (US, ID, GB, IN, ...).

## `relevanceLanguage` (type: `string`):

Prefer results in this language (ISO 639-1 code: en, id, es, ja, ...).

## `safeSearch` (type: `string`):

Filter restricted content from search results.

## `videoDuration` (type: `string`):

Video length filter (videos only).

## `videoDefinition` (type: `string`):

HD / SD filter (videos only).

## `videoCaption` (type: `string`):

Subtitle filter (videos only).

## `eventType` (type: `string`):

Live broadcast filter (videos only). Leave empty for all videos.

## `videoLicense` (type: `string`):

License filter (videos only).

## `videoType` (type: `string`):

Episode / movie filter (videos only).

## `videoEmbeddable` (type: `boolean`):

Only videos that can be embedded on other websites.

## `videoCategoryId` (type: `string`):

e.g. 10 = Music, 20 = Gaming, 17 = Sports, 25 = News & Politics, 27 = Education, 28 = Science & Technology.

## `channelId` (type: `string`):

Channel ID (UC...) to search within.

## `enrichResults` (type: `boolean`):

Fetch exact views, likes, comments, duration, tags and more for videos, subscriber and video counts for channels, and video counts for playlists. ~1 quota unit per 50 results.

## `scrapeVideoPages` (type: `boolean`):

Open each video's public page for extra fields: chapters, caption languages, channel badge and subscribers, and (optionally) related videos. Slower.

## `includeRelatedVideos` (type: `boolean`):

Only with 'Open video pages'.

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

Top-level comments to save inside each video. 0 = none. 1 quota unit per 100 comments.

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

Replies to keep under each comment. 0 = none. Extra replies cost 1 quota unit per 100.

## `commentsOrder` (type: `string`):

Order of top-level comments: YouTube's top comments or newest first.

## `includeQuerySummary` (type: `boolean`):

Total matches, views (total/average/median), top channels, top tags and hashtags, most-viewed and newest video, quota used.

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

Optional; only used for #hashtag and video pages.

## Actor input object example

```json
{
  "queries": [
    "#minecraft"
  ],
  "searchTypes": [
    "video"
  ],
  "maxResultsPerQuery": 50,
  "order": "relevance",
  "safeSearch": "moderate",
  "videoDuration": "any",
  "videoDefinition": "any",
  "videoCaption": "any",
  "videoLicense": "any",
  "videoType": "any",
  "videoEmbeddable": false,
  "enrichResults": true,
  "scrapeVideoPages": false,
  "includeRelatedVideos": false,
  "maxCommentsPerVideo": 0,
  "maxRepliesPerComment": 0,
  "commentsOrder": "relevance",
  "includeQuerySummary": true
}
```

# Actor output Schema

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

No description

## `runSummary` (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 = {
    "queries": [
        "#minecraft"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("amethys/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 = { "queries": ["#minecraft"] }

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

```

## MCP server setup

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