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

Search YouTube and get videos, channels or playlists as structured data: title, channel, views, duration, publish date, snippet. Filters for upload date, duration, type, sort order, country and language. No API key, no quota.

- **URL**: https://apify.com/serentity/youtube-search-scraper.md
- **Developed by:** [Tarik Cerkezovic](https://apify.com/serentity) (community)
- **Categories:** Videos, SEO tools, 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 $0.70 / 1,000 search results

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

Run YouTube searches and get the results as structured data. For every query you get videos (or channels, or playlists) in YouTube's order with title, channel, views, duration, publish date, live flag and description snippet. The filters are the ones on YouTube's own search page: upload date, duration, type, sort by relevance, upload date, view count or rating, plus country and language.

No YouTube API key, no daily quota, no login. Built for keyword research, trend monitoring, competitor tracking, dataset building and agents that need "what is on YouTube about X".

### What you get

| Field | Description |
|---|---|
| `query`, `position`, `estimatedResults` | The query, the 1-based rank, and YouTube's estimate of total matches |
| `type`, `id`, `url`, `title` | `video`, `channel` or `playlist`; the ID is the video, channel or playlist ID |
| `channelId`, `channelName`, `channelHandle`, `channelUrl`, `isVerifiedChannel` | Who published it |
| `durationSeconds`, `durationText` | Video length |
| `viewCount`, `viewCountText` | Views as a number and as shown |
| `publishedText`, `publishedAt` | "2 years ago" and an ISO date estimated from it |
| `isLive`, `descriptionSnippet`, `thumbnailUrl` | Live flag, the snippet YouTube shows, largest thumbnail |
| `subscriberCount`, `videoCount` | Channel results: subscribers and video count. Playlists: video count |
| `error`, `errorMessage` | Only on query-level failures |

### Sample output

```json
{
  "query": "python tutorial for beginners",
  "position": 1,
  "estimatedResults": 9914099,
  "type": "video",
  "id": "kqtD5dpn9C8",
  "url": "https://www.youtube.com/watch?v=kqtD5dpn9C8",
  "title": "Python for Beginners - Learn Coding with Python in 1 Hour",
  "channelId": "UCWv7vMbMWH4-V0ZXdmDpPBA",
  "channelName": "Programming with Mosh",
  "channelHandle": "@programmingwithmosh",
  "channelUrl": "https://www.youtube.com/@programmingwithmosh",
  "isVerifiedChannel": true,
  "durationSeconds": 3606,
  "durationText": "1:00:06",
  "viewCount": 25837819,
  "viewCountText": "25,837,819 views",
  "publishedText": "6 years ago",
  "publishedAt": "2020-11-05T16:40:00.000Z",
  "isLive": false,
  "descriptionSnippet": "... out my Complete Python Mastery course ...",
  "thumbnailUrl": "https://i.ytimg.com/vi/kqtD5dpn9C8/hq720.jpg",
  "fetchedAt": "2026-11-05T16:40:00.000Z"
}
```

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `queries` | array of strings | required | One search per entry. |
| `maxResultsPerQuery` | integer | `50` | Pages are followed until this many results are collected (up to 1,000). |
| `type` | `video`, `channel`, `playlist`, `any` | `video` | What to return. |
| `sortBy` | `relevance`, `upload_date`, `view_count`, `rating` | `relevance` | Order. |
| `uploadDate` | `any`, `hour`, `today`, `week`, `month`, `year` | `any` | Upload-date filter for videos. |
| `duration` | `any`, `short`, `medium`, `long` | `any` | Under 4 min, 4 to 20 min, over 20 min. |
| `liveOnly` | boolean | `false` | Only live streams. |
| `country`, `language` | strings | `US`, `en` | Localisation, as YouTube's own settings. |
| `maxConcurrency` | integer | `3` | Queries in parallel. |
| `proxyConfiguration` | object | Apify datacenter proxy | Proxy for all requests. |
| `residentialFallback` | boolean | `true` | Retry a blocked query through residential proxies, only on a detected block. |

Minimal input:

```json
{ "queries": ["ai agents"], "uploadDate": "week", "sortBy": "view_count" }
```

### Errors

| `error` | Meaning | Charged? |
|---|---|---|
| `NO_RESULTS` | YouTube returned nothing for the query and filters | no |
| `BLOCKED` | YouTube refused the search from every proxy tried | no |
| `FETCH_FAILED` | Network or parsing failure | no |

### Pricing

Pay per event: a small fixed amount per result item, plus Apify platform usage. Error items are free. Set a maximum total charge on the run to cap spend; the actor stops cleanly at the limit.

### Notes

- Results and their order are what YouTube shows an anonymous visitor in the chosen country and language. Personalised or signed-in results differ.
- `publishedAt` is estimated from the relative text ("2 years ago"), so it is as precise as that text.
- Shelves YouTube injects into results ("People also watched", Shorts shelves, "Latest from channel") are skipped, so positions count real results only.
- Datacenter proxies are used first; residential proxies only when a block is detected, which keeps cost low.

### Using it from code

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('serentity/youtube-search-scraper').call({ queries: ['ai agents'], maxResultsPerQuery: 100, uploadDate: 'month' });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

### Legal

The data is what YouTube's public search shows to any visitor. No login, no personal data beyond public channel names. Use it in line with YouTube's terms of service.

# Actor input Schema

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

One search per line. Each query returns up to maxResultsPerQuery results.

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

YouTube serves about 20 results per page; the actor follows pages until this many results are collected.

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

What to return. 'any' returns videos, channels and playlists mixed in YouTube's order.

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

Order of results, as on YouTube's own search filters.

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

Only videos uploaded within this period. Applies to video results.

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

short is under 4 minutes, medium 4 to 20 minutes, long over 20 minutes.

## `liveOnly` (type: `boolean`):

Only videos that are live right now.

## `country` (type: `string`):

Two-letter country code that YouTube uses to localise results, for example US, GB, DE.

## `language` (type: `string`):

Interface language code, for example en, de, es. Affects localised titles and the relative dates text.

## `maxConcurrency` (type: `integer`):

Queries processed in parallel.

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

Proxy used for the requests. Apify datacenter proxies are used by default.

## `residentialFallback` (type: `boolean`):

If YouTube blocks the datacenter proxy for a query, retry through Apify residential proxies. Only used on a detected block.

## Actor input object example

```json
{
  "queries": [
    "python tutorial for beginners",
    "lex fridman podcast"
  ],
  "maxResultsPerQuery": 50,
  "type": "video",
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "liveOnly": false,
  "country": "US",
  "language": "en",
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "residentialFallback": true
}
```

# 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 = {
    "queries": [
        "python tutorial for beginners",
        "lex fridman podcast"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("serentity/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": [
        "python tutorial for beginners",
        "lex fridman podcast",
    ],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("serentity/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": [
    "python tutorial for beginners",
    "lex fridman podcast"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call serentity/youtube-search-scraper --silent --output-dataset

```

## MCP server setup

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