# YouTube Search Scraper (videos, Shorts, channels, details) (`mathtec/youtube-search-scraper`) Actor

Scrape YouTube search results by keyword with YouTube's own filters (type, upload date, duration, features, sort): title, exact view count, duration, channel, thumbnails, rank. Optional video details: publish date, likes, comments, full description. No login. Failed searches are free.

- **URL**: https://apify.com/mathtec/youtube-search-scraper.md
- **Developed by:** [Adam Rudd](https://apify.com/mathtec) (community)
- **Categories:** Videos, Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.10 / 1,000 search result rows

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

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: search results with YouTube's own filters + optional video details

Scrape **YouTube search results by keyword**: videos, Shorts, channels, playlists or movies, using the same filters as
YouTube's own search page. Add **video details** if you need them: publish date, likes, comment count, full description,
hashtags, links and the channel's subscribers. No login, no cookies, no YouTube Data API key, so no API quota.

- **Input:** search terms, YouTube search-results links (`youtube.com/results?search_query=...`, filters in the link are
  kept), or video links and ids (`watch?v=`, `youtu.be/`, `/shorts/`, `/live/`) for one details row per video.
- **Filters (YouTube's own):** type (videos, Shorts, channels, playlists, movies, or all), prioritize (relevance or popularity),
  upload date (last hour, today, this week, this month, this year), duration (under 3 minutes, 3-20 minutes, over 20 minutes)
  and features (Live, 4K, HD, Subtitles/CC, Creative Commons, 360°, VR180, 3D, HDR, Location, Purchased). There is also an optional country (`gl`).
- **Search fields:** `id`, `url`, `title`, `viewCount` (exact for regular videos; flagged by `viewCountIsApprox`
  when YouTube rounds it), `duration` (`HH:MM:SS`), `durationSeconds`, `publishedTimeText` (for example `2 years ago`),
  `type`, `isShort`, `isLive`, `thumbnailUrl`, `thumbnails`, `channelName`, `channelId`, `channelUrl`, `channelHandle`,
  `channelAvatarUrl`, `badges`, `query`, `rank` (position in the results), `fromYTUrl`.
- **Video details (optional):** `date` (`YYYY-MM-DD`), `likes`, `commentsCount`, `commentsTurnedOff`, `text` (full
  description), `hashtags`, `descriptionLinks`, `numberOfSubscribers`.
- **Pagination:** results continue past the first page (about 20 per page) up to your `maxResultsPerQuery`.
- **Failures are free:** a search with no results, a video id that does not exist, or a link that is not YouTube returns
  a row with `status` `empty`, `failed` or `rejected` and the reason. That row is not charged.

### How to use it

1. Type one or more search terms (the form is pre-filled with `python tutorial`), or paste video or search links.
2. Pick filters: Type, Prioritize, Upload date, Duration, Features.
3. Set **Max results per search** (default 20, one page).
4. Turn on **Add video details** if you need dates, likes, comment counts and descriptions.
5. Start, then export the dataset as JSON, CSV or Excel. You can also call the Actor from the API on a schedule
   (for example, "bitcoin" uploaded today, every morning).

### Use cases

- Keyword research: which videos and channels rank for a term, and how many views they have.
- Monitoring: new uploads for a topic (`uploadDate: today` or `hour`) on a schedule.
- Lead lists: channels for a niche (`searchType: channel`) with subscriber and video counts.
- Content pipelines: find videos, then get transcripts with [YouTube Transcript](https://apify.com/mathtec/youtube-transcript),
  comments with [YouTube Comments Scraper](https://apify.com/mathtec/youtube-comments-scraper) or a channel's uploads with
  [YouTube Channel Scraper](https://apify.com/mathtec/youtube-channel-scraper).

### Input

| Field | Default | Notes |
|---|---|---|
| `searchQueries` | | search terms, as typed in YouTube's search bar |
| `startUrls` | | video links or ids (details rows) and `youtube.com/results?...` links (searches); `{"url": ...}` objects are accepted |
| `maxResultsPerQuery` | `20` | results per search term or search link |
| `searchType` | `video` | `video`, `shorts`, `channel`, `playlist`, `movie` or `all` |
| `sortBy` | `relevance` | `relevance` or `popularity` (the two orders YouTube's search page offers) |
| `uploadDate` | `any` | `any`, `hour`, `today`, `week`, `month`, `year` |
| `duration` | `any` | `any`, `under3`, `3to20`, `over20` |
| `features` | `[]` | any of `live`, `4k`, `hd`, `subtitles`, `creativeCommons`, `360`, `vr180`, `3d`, `hdr`, `location`, `purchased` |
| `includeVideoDetails` | `false` | date, likes, comment count, description, hashtags, links, subscribers (one extra request per video) |
| `searchCountry` | empty | two-letter country code sent as `gl` |

### Output example (search row with video details)

```json
{
  "input": "python tutorial",
  "status": "ok",
  "query": "python tutorial",
  "rank": 1,
  "type": "video",
  "id": "ix9cRaBkVe0",
  "url": "https://www.youtube.com/watch?v=ix9cRaBkVe0",
  "title": "Python Full Course for free 🐍",
  "viewCount": 13561756,
  "viewCountIsApprox": false,
  "date": "2024-08-20",
  "publishedTimeText": "2 years ago",
  "duration": "12:00:00",
  "durationSeconds": 43200,
  "channelName": "Bro Code",
  "channelId": "UC4SVo0Ue36XCfOyb5Lh1viQ",
  "channelUrl": "https://www.youtube.com/@BroCodez",
  "channelHandle": "@BroCodez",
  "numberOfSubscribers": 3450000,
  "likes": 379552,
  "commentsCount": 23000,
  "commentsCountIsApprox": true,
  "hashtags": ["#python", "#tutorial", "#beginners"],
  "descriptionLinks": ["https://www.python.org/", "https://www.jetbrains.com/pycharm/"],
  "fromYTUrl": "https://www.youtube.com/results?search_query=python+tutorial&sp=EgIQAQ%3D%3D"
}
```

Channel rows add `numberOfSubscribers` and `channelTotalVideos`. Playlist rows add `videoCount`.

### How much does it cost to scrape YouTube search results?

You pay per search result row, plus a **video details** event for each video whose details are read, plus a small
Actor-start event per run. The current prices for every Apify plan are on the **Pricing** tab.
On the Free plan on 2026-11-18 they were: $0.0001 per search result row, $0.0002 per video details event and $0.0009 per
Actor start. Example: 1,000 search results in one run cost $0.10; with video details on for all of them, $0.30.

Failed, rejected and empty rows are free. The run stops when your maximum charge is reached.

### Measured (local test runs, 2026-11-18)

- 3 searches x 50 results: 150/150 rows, ranks 1-50 with no gaps or duplicates, 9 requests. 147/150 view counts were exact.
  The other 3 were live streams, which show "watching" counts.
- One search x 200 results: 200/200 rows in 13 requests.
- With video details (2 runs, 300 videos): likes 299/300, publish date 294/300 (videos streamed in the last day show
  "Streamed live 12 hours ago" instead of a date), comment count 291/300, description 299/300.

### What it does not do (yet)

- **Sort by upload date or rating:** YouTube's search page no longer offers these, and in our test the old values gave the
  same order as relevance. Use the upload-date filter for recent videos.
- No subtitles or transcripts (use [YouTube Transcript](https://apify.com/mathtec/youtube-transcript)), no comments (use
  [YouTube Comments Scraper](https://apify.com/mathtec/youtube-comments-scraper)), no channel About data (join date, total
  views, country: use [YouTube Channel Scraper](https://apify.com/mathtec/youtube-channel-scraper)).
- Comment counts are rounded by YouTube above 1,000 (`commentsCountIsApprox: true`).
- Search rows for a video made by several channels together ("X and Y") have no `channelId` unless video details are on.
- Live streams have no view count (YouTube shows "N watching") and no duration.

### FAQ

**Do I need a YouTube API key or my own proxies?** No. The Actor uses Apify Proxy itself, and its cost is included in
the prices.

**Can I paste a YouTube search URL?** Yes. Put `youtube.com/results?search_query=...` links in `startUrls`. Any filters
in the link (`sp=`) are kept.

**Can I call it from code or an AI agent?** Yes, like any Apify Actor: the Apify API, the Python and JavaScript clients,
the Apify MCP server, and the Make, Zapier and n8n integrations.

**Found a problem or want a field?** Tell us on the Issues tab.

### Responsible use

You are responsible for how you use the data, including personal data and YouTube's terms.

# Actor input Schema

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

Type them as you would in YouTube's search bar. One dataset row per result.

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

Video links (watch?v=, youtu.be/, /shorts/, /live/) or 11-character video ids: one row each with the video's details. youtube.com/results?search_query=... links run as searches with the filters in the link. Objects like {"url": "..."} are accepted too.

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

Results taken per search term or search link (YouTube sends about 20 per page).

## `searchType` (type: `string`):

YouTube's Type filter. 'All' returns YouTube's mixed results (videos, playlists, channels, Shorts).

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

YouTube's own two orders. For recent videos use Upload date.

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

YouTube's Upload date filter.

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

YouTube's Duration filter.

## `features` (type: `array`):

YouTube's Features filters (all selected must match).

## `includeVideoDetails` (type: `boolean`):

Open each video for its publish date, likes, comment count, full description, hashtags, links and the channel's subscribers. Charged as a separate 'video details' event per video.

## `searchCountry` (type: `string`):

Optional two-letter country code (US, GB, DE...) to rank results for that country. Empty: YouTube decides.

## Actor input object example

```json
{
  "searchQueries": [
    "python tutorial"
  ],
  "maxResultsPerQuery": 20,
  "searchType": "video",
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "features": [],
  "includeVideoDetails": false,
  "searchCountry": ""
}
```

# Actor output Schema

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

Dataset items: input, status (ok | empty | failed | rejected), query, rank (= order), type (video | shorts | stream | channel | playlist), id, url, title, viewCount, viewCountIsApprox, viewCountText, publishedTimeText, duration (HH:MM:SS), durationSeconds, isShort, isLive, wasLive, thumbnailUrl, thumbnails, channelName, channelId, channelUrl, channelHandle, channelUsername, channelAvatarUrl, badges, shelf, fromYTUrl; channel rows: numberOfSubscribers, channelTotalVideos; playlist rows: videoCount; with video details: date, likes, commentsCount, commentsCountIsApprox, commentsTurnedOff, text (full description), hashtags, descriptionLinks, numberOfSubscribers; error when not ok.

# 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": [
        "python tutorial"
    ]
};

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

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

```

## MCP server setup

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