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

Scrape YouTube search results for any keyword. Get the title, channel, views, duration and upload date of every video, with numbers and dates ready to sort. No YouTube API key or quota needed.

- **URL**: https://apify.com/jclabs/youtube-search.md
- **Developed by:** [Julián Camilo López Sánchez](https://apify.com/jclabs) (community)
- **Categories:** Videos, Social media, SEO tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.20 / 1,000 videos

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

### What is YouTube Search Scraper?

YouTube Search Scraper extracts **YouTube search results** for any keyword. For every video you get the **title, channel, views, duration and upload date**, with counts as numbers and dates as dates, so you can sort and filter them right away.

Type your searches as you would on YouTube, choose how many videos you want from each, and click **Start**. Download the results as **JSON, CSV, Excel, XML, HTML or RSS**, or read them through the **API**. Apify's Free plan gives you $5 of credit every month, enough for about 2,500 videos at no cost.

- Search many keywords in one run and get up to 5,000 videos from each.
- Filter by upload date and sort by relevance or popularity, as on YouTube.
- Run it without a YouTube account, an API key or the daily quota of the YouTube Data API.
- Schedule it, start it from your code, or send the results to Make, Zapier, n8n and AI agents.

### What data can you extract from YouTube search?

Each video is one row with these 18 fields:

| Field | Description |
| --- | --- |
| `query` | The search the video came from |
| `position` | Rank of the video in that search, starting at 1 |
| `videoId` | YouTube video ID |
| `url` | Link to the video |
| `title` | Video title |
| `description` | The text snippet YouTube shows under the title |
| `thumbnail` | Link to the thumbnail image |
| `channel` | Channel name |
| `channelId` | Channel ID |
| `channelUrl` | Link to the channel |
| `channelVerified` | `true` if the channel has YouTube's verified badge |
| `views` | View count as a number: `1954149`, not "1.9M views" |
| `duration` | Length as YouTube shows it, such as `10:30` |
| `durationSeconds` | Length in seconds |
| `published` | Upload time as YouTube shows it, such as `5 years ago` |
| `publishedDate` | Upload date worked out from `published` (see Limitations) |
| `isLive` | `true` for live streams |
| `viewers` | People watching right now, for live streams |

### How to scrape YouTube search results

1. Click **Try for free** at the top of this page and sign in to Apify. A free account is enough.
2. Under **Searches**, enter one or more keywords, one per line.
3. If you want, change **Videos per search** (50 by default), **Uploaded** and **Order**.
4. Click **Start**. A search of 400 videos takes about 35 seconds.
5. Open the **Output** tab to see the videos, then export them in the format you need.

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

You pay **$2 per 1,000 videos** delivered, which is $0.002 per video. There is no fee per run, per search or per page, and platform usage is included. If a search returns fewer videos than you asked for, you pay only for the ones you get.

| Videos | Cost |
| --- | --- |
| 100 | $0.20 |
| 1,000 | $2 |
| 10,000 | $20 |
| 100,000 | $200 |

Paid Apify plans pay less for every video:

| Apify plan | Per 1,000 videos |
| --- | --- |
| Free | $2 |
| Starter | $1.50 |
| Scale | $1.30 |
| Business | $1.20 |

Apify's Free plan includes $5 of credit every month, which covers about 2,500 videos. To cap your spending, set a maximum cost per run in the run options. The Actor stops as soon as it reaches that amount, you are never charged more, and the run log says which search it stopped short.

### Input

**Searches** is the only required field.

| Field | What it does | Default |
| --- | --- | --- |
| **Searches** (`queries`) | Keywords to search, one per line, as you would type them on YouTube | Required |
| **Videos per search** (`maxResults`) | How many videos to get from each search, from 1 to 5,000 | 50 |
| **Uploaded** (`uploaded`) | `any`, `hour`, `today`, `week`, `month` or `year` | `any` |
| **Order** (`sortBy`) | `relevance`, as on YouTube, or `popularity`, most watched first | `relevance` |

The same input in JSON, for runs started from the API:

```json
{
  "queries": ["python tutorial", "home workout"],
  "maxResults": 100
}
```

### Output

Each video is a row in the dataset, in the order YouTube returned it. This is the first result for `python tutorial`:

```json
{
  "query": "python tutorial",
  "position": 1,
  "videoId": "fWjsdhR3z3c",
  "url": "https://www.youtube.com/watch?v=fWjsdhR3z3c",
  "title": "Learn Python in Less than 10 Minutes for Beginners (Fast & Easy)",
  "description": "In this crash course I'll be teaching you the basics of Python ...",
  "thumbnail": "https://i.ytimg.com/vi/fWjsdhR3z3c/hqdefault.jpg",
  "channel": "Indently",
  "channelId": "UCuudpdbKmQWq2PPzYgVCWlA",
  "channelUrl": "https://www.youtube.com/@Indently",
  "channelVerified": true,
  "views": 1954149,
  "duration": "10:30",
  "durationSeconds": 630,
  "published": "5 years ago",
  "publishedDate": "2021-11-21",
  "isLive": false,
  "viewers": null
}
```

Live streams have `isLive: true` and a `viewers` count, and no `views`, `duration` or `publishedDate`. Only videos are returned: channels, playlists and Shorts shelves are left out, and a video that YouTube repeats on a later page appears once.

### Limitations

- `publishedDate` is an estimate. YouTube search only says "5 years ago", so the date is the day of the run minus that. Use it to sort or filter by period, not as the exact upload day.
- YouTube decides how many results a search has. Narrow searches can end before your limit.
- Results are what YouTube shows a visitor from the United States with the interface in English.
- When a video has two channels, `channel` shows both names as YouTube does, and `channelId` and `channelUrl` belong to the first one.
- Counts that are not views or viewers, such as "12 waiting" on a premiere, are left empty instead of guessed.
- A result that YouTube sends in a shape the Actor can't read is skipped and not charged.
- Only public search results are read: no private videos, comments, transcripts or anything that needs an account.

### FAQ

#### Is it legal to scrape YouTube search results?

The Actor collects only public information that YouTube shows to anyone, without logging in or getting around any block. Results can still include personal data, such as the name of a channel run by a person, and laws like the GDPR protect that data. Collect it only for a legitimate purpose, and ask a lawyer if you are unsure.

#### Can I use it as a YouTube search API?

Yes. Every run can be started and read through the Apify API, and the **API** tab on this page has examples ready to copy in Python, JavaScript and cURL. Unlike the YouTube Data API, there is no daily quota and no Google project to set up.

#### How fast is it?

A search of 400 videos takes about 35 seconds. YouTube sends about 20 videos per page, one page after another, so most of that time is spent waiting for YouTube. Up to five searches run in parallel.

#### Why did I get fewer videos than I asked for?

YouTube ran out of results for that search, and you pay only for the videos you got. Broader keywords or a longer upload period return more.

#### How do I get the subscribers of the channels I found?

Paste the `channelId` of the videos into [YouTube Channel Scraper](https://apify.com/jclabs/youtube-channel-scraper). It returns each channel's subscribers, total views, video count and latest videos.

#### How do I get the comments of the videos I found?

Paste the links or video IDs into [YouTube Comments Scraper](https://apify.com/jclabs/youtube-comments-scraper). It returns each comment with its author, likes, replies and date, and the replies themselves if you want them.

#### What can I use YouTube search data for?

- Research a topic before you film: see what already ranks, with views and length side by side.
- Follow a trend: schedule the same searches with **Uploaded** set to this week and see new videos as they appear.
- Track a brand, a product or a competitor, and see who covers it.
- Build lists of channels that publish in a niche, with their IDs and links.
- Collect video IDs on a topic for the next step of an AI pipeline, such as transcripts or summaries.

### Support

Found a bug, or need a field that isn't there? Open an issue in the **Issues** tab with the input you used. The Actor is tested against YouTube every day, so a change on YouTube's side is spotted within a day.

# Actor input Schema

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

What you would type in the YouTube search box, one search per line. The same search typed twice runs once.

## `maxResults` (type: `integer`):

How many videos to return for each search. YouTube returns about 20 per page; the Actor keeps asking for the next page until it has this many or YouTube has no more.

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

Keep only videos uploaded within this period.

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

Relevance is YouTube's default order. Popularity puts the most watched videos first, as YouTube ranks them (close to, but not exactly, by view count).

## Actor input object example

```json
{
  "queries": [
    "python tutorial"
  ],
  "maxResults": 50,
  "uploaded": "any",
  "sortBy": "relevance"
}
```

# Actor output Schema

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

One row per video, in the order YouTube returned it, with title, channel, views, duration and upload date.

# 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"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jclabs/youtube-search").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"] }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jclabs/youtube-search"
        }
    }
}
```

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/wTacjKDU3Wi7a6Amv/builds/ptgwLoiVHvUQIeDNd/openapi.json
