# YouTube Search Scraper - Video Results by Keyword & Filters (`mochiboo/youtube-search-filters-scraper`) Actor

Search YouTube by keyword and filter the way the site does: upload date, duration, 4K, subtitles, sort by views, plus Shorts search. Exact view counts, channel, verified badge, duration and description snippet for every result.

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

## Pricing

from $0.80 / 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?

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 - videos and Shorts by keyword, with real filters

Search YouTube the way the site does and get structured rows: exact view counts, channel, verified badge, duration and the description snippet for every result.

- **Search by keyword, sorted and filtered.** Sort by relevance or view count; filter by upload date (last hour, today, this week, this year), duration (under 4 minutes, 4-20 minutes, over 20 minutes), 4K and subtitles/CC.
- **Exact view counts.** `3,394,425 views` is returned as the number `3394425`, not `3.4M`, together with the channel, channel link, verified badge, duration in seconds and the description snippet.
- **Shorts search included.** Switch `contentType` to `shorts`. Pay per result: see the pricing on this page.

### What you get

One row per result. Video row:

```json
{"query":"sourdough bread","position":1,"contentType":"video","videoId":"4gEoh3sk2AE","url":"https://www.youtube.com/watch?v=4gEoh3sk2AE","title":"Bake the Perfect Sourdough Bread: A Step-by-Step Guide","channelName":"Natashas Kitchen","channelId":"UC-pC1xsFPzcrL09DaW4jlBA","channelHandle":"@Natashaskitchen","channelUrl":"https://www.youtube.com/@Natashaskitchen","isVerifiedChannel":true,"publishedText":"2 years ago","viewCount":3394425,"viewCountText":"3,394,425 views","durationText":"11:53","durationSeconds":713,"descriptionSnippet":"Learn how to bake sourdough bread with the perfect rise, ear, and texture...","badges":["5 products","Earns commission"],"thumbnailUrl":"https://i.ytimg.com/vi/4gEoh3sk2AE/hqdefault.jpg","filters":{"sortBy":"relevance","uploadDate":"any","duration":"any","subtitles":false,"fourK":false},"scrapedAt":"2026-10-19T09:26:05.034Z"}
```

- `position` counts results per query from 1. `filters` echoes the settings that were applied.
- `publishedText` is YouTube's relative date (`2 years ago`, `5 hours ago`), not a calendar date.
- Shorts rows have `contentType` `short`, a `/shorts/` url, the title, `viewCountText` as YouTube shows it (`3.6M views`) and `viewCountApprox` (that text as a number, so rounded the way YouTube rounds it). Shorts search results carry no channel, duration or publish date, so those fields are not in Shorts rows.
- Collaboration videos ("A and 2 more") have no single channel: `channelId`, `channelHandle` and `channelUrl` are `null` there. A handle can also be missing on other videos (16 of 50 rows in one test search), so treat `channelHandle` as optional. A stream that is live right now has no view count, publish date or duration yet, so those are `null` until it ends.
- `badges` is whatever YouTube shows on the result (`4K`, `CC`, `5 products`, ...). The 4K and subtitles filters are applied by YouTube; the badge is not guaranteed on every filtered result.

### Input

| Field | Default | What it does |
|---|---|---|
| `searchQueries` | one example | Keywords to search (up to 200 per run). |
| `maxResultsPerQuery` | `50` (max `1000`) | Results per query. |
| `contentType` | `videos` | `videos` or `shorts`. |
| `sortBy` | `relevance` | `relevance` or `viewCount`. View-count order is approximate: YouTube sorts on cached counts, so neighbouring results can be slightly out of order. |
| `uploadDate` | `any` | `lastHour`, `today`, `thisWeek` or `thisYear`. |
| `duration` | `any` | `short` (under 4 min), `medium` (4-20 min) or `long` (over 20 min). |
| `subtitles`, `fourK` | `false` | Only videos with subtitles/CC; only 4K videos. |
| `proxyConfiguration` | Apify datacenter proxy | Proxy used for all requests. |

For Shorts search, YouTube's filters were not verified, so `sortBy`, `uploadDate`, `duration`, `subtitles` and `fourK` are ignored and the log says which. Not offered, because YouTube ignores them in our tests: sort by upload date, sort by rating, "this month".

### Measured behaviour

Platform runs on 2026-10-19, default datacenter proxy, 512 MB:

- `sourdough bread` + `standing desk review`, 60 each: 120 rows in 6.9 seconds. Title, channel name, channel id and handle, view count, duration, publish text and description snippet were filled in 120 of 120 rows; 56 of 120 had a verified channel; positions ran 1-60 without gaps for both queries.
- `iphone 18 review`, this week + 4-20 minutes + sort by views, 40 requested: 40 rows, every `publishedText` in minutes, hours or days, every duration between 240 and 1,200 seconds.
- Shorts search `sourdough`, 60 requested: 60 rows, all `short`, all `/shorts/` links.
- Nothing was blocked on the default proxy in any run (0 blocked of 6 runs).
- Peak memory 48-76 MB on small runs, 132 MB on the 1,288-row run below. The same 120-row run took 6.9 s at 512 MB and 4.4 s at 4096 MB.

### Stopping early, blocks and the run summary

- The run keeps a time budget. A very large run (up to 200 queries at 1,000 results each) may stop early: it starts no new request, writes what it has and ends as succeeded. The `RUN_SUMMARY` record (`complete`, `terminationReason`, `rowsPushed`) says whether it finished or stopped early; `terminationReason` is one of `finished`, `max_results`, `charge_limit`, `time_budget`, `blocked`, `request_failed`. Checked with the maximum input and a 45-second timeout: succeeded after 36 seconds with 1,288 rows and `time_budget`.
- If YouTube answers with HTTP 403, a consent page or a sign-in page, the actor stops at once with `YouTube blocked the request (HTTP <status>); stopping.` and keeps the rows already written. It never retries a block. Run again later.
- Temporary errors (HTTP 429, 5xx, network) are retried three times (2, 4, 8 seconds); a page that still fails ends only that query and the summary says `request_failed`.
- Results are billed per row; if you set a maximum charge per run the run stops there.

### Privacy

Only public, logged-out YouTube search results are read: no login, no cookies. Email addresses and phone numbers in titles, channel names and description snippets are replaced with `[email redacted]` and `[phone redacted]` (best effort on the formats it recognises).

### Keywords

youtube search scraper, youtube keyword scraper, youtube video search api, youtube search results, youtube shorts search, youtube filters, youtube videos by keyword, trending youtube videos

# Actor input Schema

## `searchQueries` (type: `array`):

What to search for on YouTube, one keyword or phrase per line. Up to 200 per run.

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

Results returned for each search query (1-1000). You get fewer if YouTube runs out of results for that query.

## `contentType` (type: `string`):

Search videos or Shorts. For Shorts the filters below are ignored.

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

Relevance is YouTube's default ranking. View count puts the most viewed first; YouTube sorts on cached counts, so neighbouring results can be slightly out of order.

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

Only videos uploaded within this period.

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

Only videos of this length.

## `subtitles` (type: `boolean`):

Keep only videos that have subtitles / closed captions.

## `fourK` (type: `boolean`):

Keep only videos available in 4K.

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

Apify Proxy is on by default.

## Actor input object example

```json
{
  "searchQueries": [
    "sourdough bread"
  ],
  "maxResultsPerQuery": 50,
  "contentType": "videos",
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "subtitles": false,
  "fourK": false,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

One row per video or Short found by the search, with query, position, exact view count, channel, duration and description snippet.

## `runSummary` (type: `string`):

What the run wrote and how it ended (the RUN_SUMMARY record in the default key-value store).

# 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 = {
    "searchQueries": [
        "sourdough bread"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("mochiboo/youtube-search-filters-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 = {
    "searchQueries": ["sourdough bread"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("mochiboo/youtube-search-filters-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 '{
  "searchQueries": [
    "sourdough bread"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call mochiboo/youtube-search-filters-scraper --silent --output-dataset

```

## MCP server setup

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