# YouTube Search Scraper — Videos, Channels & Playlists (`datakiln/youtube-search-scraper`) Actor

Scrape YouTube search results for any keyword with YouTube's own filters (upload date, duration, type, 4K, live, subtitles). Get titles, views, dates, durations, channels and links. Expand with YouTube suggestions for hundreds of results.

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

## Pricing

$0.50 / 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, channels & playlists

Scrape **YouTube search results** for any keyword — exactly what you'd see in the YouTube search bar — with YouTube's own filters: **upload date, duration, type (videos / channels / playlists) and features** like Live, 4K, HD, subtitles or Creative Commons. No API key, no quota, no login.

**$0.50 per 1,000 results.**

### Use cases

- 🔎 **Keyword & trend research** — what ranks for a topic this week, how many views it gets.
- 🎯 **Competitor & content gap analysis** — top videos and channels for your niche.
- 🤝 **Influencer discovery** — switch *Result type* to *Channels* and feed them into our [YouTube Channel Email Finder](https://apify.com/datakiln/youtube-channel-email-finder).
- 🧠 **AI / RAG pipelines** — fresh video lists with titles, snippets and links.

### Input example

```json
{
  "searchQueries": ["python tutorial", "ai agents"],
  "maxResultsPerQuery": 200,
  "resultType": "video",
  "uploadDate": "month",
  "duration": "long",
  "features": ["subtitles"],
  "sortBy": "views",
  "minViews": 10000,
  "expandWithSuggestions": true
}
```

### Output example (video)

```json
{
  "type": "video",
  "rank": 1,
  "position": 4,
  "videoId": "abc123xyz00",
  "url": "https://www.youtube.com/watch?v=abc123xyz00",
  "title": "How to Build AI Agents in Python - 3 Ways",
  "channelTitle": "Tech With Tim",
  "channelId": "UC4JX40jDee_tINbkjycV4Sg",
  "channelUrl": "https://www.youtube.com/@TechWithTim",
  "isVerifiedChannel": true,
  "viewCount": 50902,
  "publishedText": "2 weeks ago",
  "approxPublishedDate": "2026-09-25",
  "durationText": "32:18",
  "durationSeconds": 1938,
  "isLive": false,
  "badges": ["CC"],
  "descriptionSnippet": "In this video I'll show you…",
  "thumbnailUrl": "https://i.ytimg.com/vi/abc123xyz00/hq720.jpg",
  "searchQuery": "python tutorial"
}
```

Channel results include `title`, `handle`, `subscribers`, `descriptionSnippet`; playlist results include `playlistId`, `title` and details.

### Pricing

Pay-per-result: **$0.0005 per result** ($0.50 per 1,000), platform usage included. Cap any run with *Max total charge*.

### FAQ

**Why is sorting done by the scraper?** YouTube no longer applies "sort by views/date" consistently to search results. We collect results in YouTube's own order (`position`) and then sort them by views or date within each keyword (`rank`). Filters such as upload date, duration and type are sent to YouTube **and** re-checked on every result — YouTube only honours them for roughly the first 40 results and then mixes in unfiltered videos, which this scraper drops.

**How many results per keyword?** YouTube serves roughly 75–100 unique results per search to signed-out users. Turn on **Expand with YouTube suggestions** and the scraper also searches YouTube's own autocomplete variations of your keyword, multiplying the number of unique results. `matchedQuery` shows which variation found each item.

**Are dates exact?** Search shows relative dates ("2 weeks ago"); `approxPublishedDate` converts them to an approximate day. For exact dates use our [YouTube Channel Videos Scraper](https://apify.com/datakiln/youtube-channel-videos-scraper) with details on.

**Is it legal?** It collects public search results. Follow YouTube's terms and local law when using the data.

### Related tools by DataKiln

- [YouTube Channel Email Finder — creator emails, socials & stats](https://apify.com/datakiln/youtube-channel-email-finder)
- [YouTube Comments Scraper — comments, replies & likes](https://apify.com/datakiln/youtube-comments-scraper)
- [YouTube Channel Videos Scraper — videos, Shorts & lives](https://apify.com/datakiln/youtube-channel-videos-scraper)

### Support

Open an issue on the **Issues** tab — we usually reply within 24 hours.

# Actor input Schema

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

What you would type into YouTube search. Each keyword is searched separately.

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

How many results to collect per keyword. YouTube serves roughly 75–100 unique results per search — turn on 'Expand with YouTube suggestions' to go beyond that.

## `expandWithSuggestions` (type: `boolean`):

Also search YouTube's autocomplete suggestions for each keyword (e.g. 'ai agents' → 'ai agents tutorial', 'ai agents explained') to collect far more unique results. Results stay grouped under your original keyword.

## `resultType` (type: `string`):

What kind of results to return.

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

YouTube's upload-date filter (videos).

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

YouTube's duration filter (videos).

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

YouTube's feature filters: live, 4K, HD, subtitles/CC, Creative Commons, 360°, VR180, 3D, HDR, location, purchased.

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

YouTube no longer applies view/date sorting reliably to search, so results are collected in YouTube's order and sorted by the scraper within each keyword.

## `minViews` (type: `integer`):

Skip videos with fewer views.

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

Not required. Leave empty unless you see blocking.

## Actor input object example

```json
{
  "searchQueries": [
    "python tutorial"
  ],
  "maxResultsPerQuery": 50,
  "expandWithSuggestions": false,
  "resultType": "video",
  "uploadDate": "any",
  "duration": "any",
  "sortBy": "relevance"
}
```

# Actor output Schema

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

All results as JSON items.

## `overview` (type: `string`):

Overview table view.

# 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"
    ],
    "maxResultsPerQuery": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("datakiln/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"],
    "maxResultsPerQuery": 50,
}

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

```

## MCP server setup

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