# YouTube Search Scraper - Videos, Channels, Views & Filters (`socialscrapers/youtube-search-scraper`) Actor

YouTube Search Scraper: scrape YouTube search results for any keyword: videos with exact views, likes, comment count, publish date, duration, tags and channel subscribers, or channels. YouTube's own filters: upload date, duration, 4K, sort by views. No login or API key. $0.46 per 1,000 results.

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

## Pricing

from $0.37 / 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

**YouTube Search Scraper** turns any keyword into a clean list of **YouTube search results**: every video with its **exact views, likes and comment count, publish date, duration, tags, hashtags and category**, plus the channel behind it and its subscribers. Use YouTube's own search filters (upload date, duration, 4K, HD, subtitles, live) and sort by relevance or by views, or search for **channels** instead of videos. **No login, no API key, no quota**: download JSON, CSV or Excel for **$0.46 per 1,000 results**.

> 💡 **Need a feature that isn't here? Just ask.** Open an issue on the **Issues** tab and tell us what you need: a new field, filter, input type or output format. We build requested features fast, usually within 24 hours, at no extra cost.

> ⭐ **Found it useful?** A short review on the **Reviews** tab helps other people find this scraper, and tells us what to build next.

### What does YouTube Search Scraper do?

- 🔎 **Searches YouTube for each keyword** you give, exactly like the search box on youtube.com, and keeps each result's rank.
- 🎛️ **YouTube's search filters**: result type (videos, Shorts, live, movies, channels), upload date (last hour to this year), duration (under 3 minutes, 3 to 20 minutes, over 20 minutes), features (4K, HD, Subtitles/CC, Creative Commons, 360°, VR180, 3D, HDR, Location, Purchased) and sort by relevance or most viewed.
- 📅 **Exact date range**: only videos published after or before a date, or within an age such as "7 days" or "6 months".
- 📊 **Full numbers, not search snippets**: each result comes with its exact views, likes and comment count, not the rounded "1.2M views" of the results page.
- 📺 **Channel search**: with the Channels result type, each channel found is saved with its subscribers, total videos and views, country, join date, description and links.
- ✅ **Each video once per run**, even when several keywords find it, and **pay only for results saved**, with a maximum cost per run if you want one.

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

| Item | Data |
| --- | --- |
| **Video** | title, description, URL, publish date and time, duration, exact views, likes, comment count, comments turned off, tags, hashtags, category, thumbnail, chapters, links in the description, Short or live, members-only, age-restricted, paid promotion |
| **Channel of each video** | channel name, @handle, URL and ID, subscribers, verified badge |
| **Where it was found** | the keyword, the search URL with its filters, and the rank of the result |
| **Channel** (Channels result type) | name, @handle, URL and ID, description, subscribers, total videos and views, join date, country, links, keywords, avatar, banner, verified badge |

### How to scrape YouTube search results

1. Open YouTube Search Scraper on Apify and click **Try for free**.
2. Type your **search terms**, one per line. They go to YouTube as written, so its own search syntax (`"exact phrase"`, `-word`, `|` for OR) works, at any length.
3. Set **Max results per search term**.
4. Optionally pick the **result type**, **sort order**, **upload date**, **duration** and **features**, or a **date range**.
5. Click **Start**, then download the results as JSON, CSV, Excel, XML or HTML, or read them through the API.

#### How to find the most viewed videos for a keyword

Choose **Popularity (most viewed)** as the sort order. Add an upload date such as **This month** to see what is popular right now rather than of all time.

#### How to find YouTube channels about a topic

Choose **Channels** as the result type. Each channel found is saved once, with its subscribers, number of videos, total views, country and links: a quick way to build a list of creators in a niche.

#### How to keep only long videos, or only 4K

Pick **Over 20 minutes** as the duration, or tick **4K** under features. Several features can be combined: each result then has all of them.

#### How to get only new videos for a keyword

Set **Published on or after** to an age such as `1 day` and schedule the run daily. When no upload date filter is chosen, the scraper picks the tightest one that still covers your date range, so it reads fewer pages.

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

Pay per result, with platform usage and proxies included and no monthly fee for the Actor:

| Result | Price per 1,000 | Silver plan | Gold plan |
| --- | --- | --- | --- |
| Videos (Shorts and live streams included) | **$0.46** | $0.414 | $0.368 |
| Channels (Channels result type) | **$0.46** | $0.414 | $0.368 |

Each run also has Apify's standard **Actor start** charge: $0.001 per run (one event per GB of memory, at least one; this Actor uses at most 1 GB, so one event per run).

Examples:

- **1,000 search results** for one keyword: **$0.46**.
- **50 keywords with 200 results each** (10,000 videos): **$4.60**.
- **300 channels** from a channel search: **$0.14**.

Apify's free plan comes with $5 of platform credit every month, enough for about 10,000 search results. Set a **maximum cost per run** and the scraper stops cleanly before the first result that would go over it.

### Input example

```json
{
  "searchQueries": ["sourdough bread recipe", "no knead bread"],
  "maxResultsPerQuery": 200,
  "searchType": "video",
  "sortBy": "popularity",
  "uploadDate": "year",
  "duration": "medium",
  "features": ["hd"]
}
```

### Output example

The most viewed result of the past year for `sourdough bread recipe`:

```json
{
  "dataType": "video",
  "id": "ukMbpMuof3g",
  "url": "https://www.youtube.com/watch?v=ukMbpMuof3g",
  "title": "Never Buy Bread Again: The Easiest 4-Ingredient Daily Bread (No Kneading)",
  "description": "#bread, #baking, #recipe\n@FastEasyDelicious1\n\nWelcome to the “Fast Easy Delicious” virtual family ❤️ ...",
  "publishedAt": "2026-01-06T16:01:34.000Z",
  "durationSeconds": 385,
  "duration": "00:06:25",
  "viewCount": 5511500,
  "likeCount": 137486,
  "commentCount": 11534,
  "commentsTurnedOff": false,
  "tags": ["bread recipe", "no knead bread", "homemade bread", "artisan bread"],
  "hashtags": ["#bread", "#baking", "#recipe"],
  "category": "Education",
  "thumbnail": "https://i.ytimg.com/vi/ukMbpMuof3g/maxresdefault.jpg",
  "videoType": "video",
  "isShort": false,
  "liveStatus": "none",
  "channelId": "UCdDBPeFs-uj5E7z8mIyTDIw",
  "channelName": "Fast Easy Delicious",
  "channelHandle": "@FastEasyDelicious1",
  "channelUrl": "https://www.youtube.com/@FastEasyDelicious1",
  "channelSubscriberCount": 364000,
  "channelIsVerified": true,
  "sourceType": "search",
  "sourceUrl": "https://www.youtube.com/results?search_query=sourdough%20bread%20recipe&sp=CAMSBAgFEAE%3D",
  "searchQuery": "sourdough bread recipe",
  "position": 1,
  "scrapedAt": "2026-11-12T22:28:25.478Z"
}
```

With the **Channels** result type, a channel found for `sourdough`:

```json
{
  "dataType": "channel",
  "id": "UCFfhvjvRMWDeJhX88dv-EmQ",
  "url": "https://www.youtube.com/@FarmhouseonBoone",
  "name": "Farmhouse on Boone",
  "handle": "@FarmhouseonBoone",
  "subscriberCount": 746000,
  "videoCount": 1160,
  "viewCount": 130276632,
  "joinedAt": "2016-02-25",
  "country": "United States",
  "links": [{ "title": "Blog", "url": "http://www.farmhouseonboone.com" }],
  "keywords": ["farmhouse style", "whole food", "sourdough"],
  "isVerified": false,
  "sourceType": "search",
  "searchQuery": "sourdough"
}
```

### Use cases

- **YouTube SEO and keyword research**: what ranks for a keyword, how long those videos are, which tags and hashtags they use.
- **Competitor tracking**: who ranks for your product category, and how their views grow from week to week.
- **Trend spotting**: the most viewed videos for a topic this week or this month.
- **Influencer and creator discovery**: channel search turns a topic into a list of creators with their audience size and links.
- **Datasets for research and AI**: thousands of video titles, descriptions and engagement numbers for a set of keywords.

### Use it via API, Python, JavaScript and integrations

Run it and get the results in one call with the [Apify API](https://docs.apify.com/api/v2):

```bash
curl -X POST "https://api.apify.com/v2/acts/socialscrapers~youtube-search-scraper/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"searchQueries": ["sourdough bread recipe"], "maxResultsPerQuery": 50, "sortBy": "popularity"}'
```

Python, with the [Apify client](https://docs.apify.com/api/client/python):

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("socialscrapers/youtube-search-scraper").call(run_input={
    "searchQueries": ["mechanical keyboard review"],
    "maxResultsPerQuery": 100,
    "uploadDate": "month",
})
for video in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(video["position"], video["title"], video["viewCount"])
```

JavaScript, with the [Apify client](https://docs.apify.com/api/client/js):

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
const run = await client.actor('socialscrapers/youtube-search-scraper').call({ searchQueries: ['home espresso'], searchType: 'channel', maxResultsPerQuery: 50 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

Schedule runs, get a webhook when one finishes, or send the results to **Make, Zapier, n8n, Google Sheets** and other tools through [Apify integrations](https://docs.apify.com/integrations). AI agents and assistants can run it through [Apify's MCP server](https://docs.apify.com/mcp).

### YouTube Data API vs YouTube Search Scraper

| | Official YouTube Data API | YouTube Search Scraper |
| --- | --- | --- |
| Setup | Google Cloud project and API key | None: type your keywords |
| Limits | 10,000 quota units a day by default; each search page costs 100 units | No quota |
| Numbers in search results | Titles and snippets only; views and likes need a second request per video | Exact views, likes and comment count with every result |
| Price | Free within the quota | $0.46 per 1,000 results |

### Limits

- **Public results only.** The scraper never signs in, so the results are what a visitor who is not signed in sees.
- **YouTube shows up to several hundred results per search term.** For more, add related terms, or split one term by upload date or duration.
- **Language and region**: results are read in English, as YouTube ranks them for a visitor in the United States.
- **Subscriber counts** are as precise as YouTube shows them ("364K" becomes 364000). Video views, likes and comment counts are exact.
- **A run with 0 results still succeeds.** When a search finds nothing (or nothing left after the filters), the run ends as Succeeded with a status message naming the search term, and nothing is charged. When nothing in the input can be used at all, the run also ends as Succeeded, with a status message that starts "Nothing to scrape:" and says what to fix; no results are charged. A run fails only when YouTube refuses every one of 3 or more search terms and a well-known public channel is refused too (the scraper is then blocked; try again later).
- **Runs stop in time.** A run that is about to reach its timeout stops a little early, keeps every result it saved and ends as Succeeded; raise the timeout to get more.

### FAQ

**Is it legal to scrape YouTube search results?**
YouTube Search Scraper collects only data that anyone can see without signing in. Results can include personal data such as creators' names, which laws such as the GDPR protect, so collect only what you need. You are responsible for how you use the data and for following YouTube's terms and the laws that apply to you.

**Do I need a YouTube API key or account?**
No. Type your search terms and start the run.

**Why are the results different from what I see on YouTube?**
YouTube personalizes search for signed-in users and adapts it to your country and language. The scraper sees what a signed-out visitor sees, which is the most neutral view of the rankings.

**Can I get the comments or subtitles of the videos I find?**
Yes, with [YouTube Scraper](https://apify.com/socialscrapers/youtube-scraper), which runs the same searches and adds comments, replies and subtitles, or with [YouTube Comments Scraper](https://apify.com/socialscrapers/youtube-comments-scraper) and [YouTube Transcript Scraper](https://apify.com/socialscrapers/youtube-transcript-scraper) on the video URLs.

**Can I search YouTube Shorts only?**
Yes: choose **Shorts** as the result type. [YouTube Shorts Scraper](https://apify.com/socialscrapers/youtube-shorts-scraper) also reads the Shorts of channels and hashtags.

**Does it download the videos?**
No. It collects data about the videos, not the video files.

### Other scrapers by Social Scrapers

| Scraper | What it gets |
| --- | --- |
| [TikTok API](https://apify.com/socialscrapers/tiktok-api) | Profiles, Videos and Comments |
| [TikTok Comments Scraper](https://apify.com/socialscrapers/tiktok-comments-scraper) | Comments, Replies and Likes |
| [TikTok Hashtag Scraper](https://apify.com/socialscrapers/tiktok-hashtag-scraper) | Top Videos, Views and Likes |
| [TikTok Profile Scraper](https://apify.com/socialscrapers/tiktok-profile-scraper) | Followers, Bio, Stats and Videos |
| [TikTok Scraper](https://apify.com/socialscrapers/tiktok-scraper) | Videos, Profiles, Hashtags and Comments |
| [TikTok Sound Scraper](https://apify.com/socialscrapers/tiktok-sound-scraper) | Videos Using a Sound and Music Info |
| [TikTok Video Scraper](https://apify.com/socialscrapers/tiktok-video-scraper) | Views, Likes, Captions and Comments |
| [Instagram API](https://apify.com/socialscrapers/instagram-api) | Profiles, Posts, Reels, Comments and Hashtags |
| [Instagram Comments Scraper](https://apify.com/socialscrapers/instagram-comments-scraper) | Comments, Likes and Reply Counts |
| [Instagram Hashtag Scraper](https://apify.com/socialscrapers/instagram-hashtag-scraper) | Reels and Keyword Search |
| [Instagram Post Details Scraper](https://apify.com/socialscrapers/instagram-post-details-scraper) | Likes, Comments, Views and Media |
| [Instagram Post Scraper](https://apify.com/socialscrapers/instagram-post-scraper) | Posts, Reels and Comments |
| [Instagram Profile Scraper](https://apify.com/socialscrapers/instagram-profile-scraper) | Followers, Bio, Posts and Reels |
| [Instagram Reels Scraper](https://apify.com/socialscrapers/instagram-reels-scraper) | Reels, Plays, Likes and Comments |
| [Instagram Reels Transcript Scraper](https://apify.com/socialscrapers/instagram-reels-transcript-scraper) | Speech to Text and Captions |
| [Instagram Scraper](https://apify.com/socialscrapers/instagram-scraper) | Posts, Profiles, Reels, Comments and Hashtags |
| [YouTube API](https://apify.com/socialscrapers/youtube-api) | Videos, Transcripts, Search, Channels and Comments |
| [YouTube Channel Scraper](https://apify.com/socialscrapers/youtube-channel-scraper) | Videos, Shorts, Subscribers and About |
| [YouTube Comments Scraper](https://apify.com/socialscrapers/youtube-comments-scraper) | Comments, Replies and Likes |
| [YouTube Scraper](https://apify.com/socialscrapers/youtube-scraper) | Videos, Shorts, Channels and Comments |
| [YouTube Shorts Scraper](https://apify.com/socialscrapers/youtube-shorts-scraper) | Shorts, Views, Likes and Search |
| [YouTube Transcript Scraper](https://apify.com/socialscrapers/youtube-transcript-scraper) | Subtitles, Captions and SRT |
| [YouTube Video Details Scraper](https://apify.com/socialscrapers/youtube-video-details-scraper) | Stats, Subtitles and Comments |
| [Facebook Ads Library Scraper](https://apify.com/socialscrapers/facebook-ads-library-scraper) | Meta Ad Library and Spend |
| [Facebook Comments Scraper](https://apify.com/socialscrapers/facebook-comments-scraper) | Posts, Reels, Videos and Replies |
| [Facebook Groups Scraper](https://apify.com/socialscrapers/facebook-groups-scraper) | Public Group Posts and Reactions |
| [Facebook Marketplace Scraper](https://apify.com/socialscrapers/facebook-marketplace-scraper) | Prices, Locations and Sellers |
| [Facebook Page Contact Info Scraper](https://apify.com/socialscrapers/facebook-page-contact-scraper) | Email, Phone and WhatsApp |
| [Facebook Posts Scraper](https://apify.com/socialscrapers/facebook-profile-posts-scraper) | Pages, Profiles and Timelines |
| [Facebook Pages Scraper](https://apify.com/socialscrapers/facebook-profile-scraper) | Profiles, Contact Info and Reviews |
| [Facebook Reels Scraper](https://apify.com/socialscrapers/facebook-reels-scraper) | Reels, Videos, Plays and Captions |
| [X (Twitter) Profile Scraper](https://apify.com/socialscrapers/x-profile-scraper) | Followers, Bio and Tweets |
| [X (Twitter) Tweet Scraper](https://apify.com/socialscrapers/x-tweet-scraper) | Latest Posts by Profile |
| [Threads Profile Scraper](https://apify.com/socialscrapers/threads-profile-scraper) | Followers, Bio, Links and Posts |
| [Threads Replies Scraper](https://apify.com/socialscrapers/threads-replies-scraper) | Comments, Authors, Likes and Media |
| [Threads Scraper](https://apify.com/socialscrapers/threads-scraper) | Posts, Profiles, Replies and Search |
| [Threads Search Scraper](https://apify.com/socialscrapers/threads-search-scraper) | Keywords, Hashtags, Top and Recent Posts |
| [Reddit Comments Scraper](https://apify.com/socialscrapers/reddit-comments-scraper) | Threads, Replies, Votes and Authors |
| [Reddit Scraper](https://apify.com/socialscrapers/reddit-scraper) | Posts, Comments, Subreddits, Users and Search |
| [Reddit Search Scraper](https://apify.com/socialscrapers/reddit-search-scraper) | Posts by Keyword, Subreddit and Date |
| [Reddit User Scraper](https://apify.com/socialscrapers/reddit-user-scraper) | Profiles, Karma, Posts and Comments |
| [Subreddit Scraper](https://apify.com/socialscrapers/subreddit-scraper) | Hot, New and Top Posts with Comments |
| [Quora Scraper](https://apify.com/socialscrapers/quora-scraper) | Answers, Questions, Profiles and Topic Search |
| [LinkedIn Ad Library Scraper](https://apify.com/socialscrapers/linkedin-ad-library-scraper) | Ads, Advertisers and Impressions |
| [LinkedIn Job Search Scraper](https://apify.com/socialscrapers/linkedin-job-search-scraper) | Filters, Salaries and New Jobs |
| [LinkedIn Jobs Scraper](https://apify.com/socialscrapers/linkedin-jobs-scraper) | Job Listings, Salaries and Companies |
| [Google Maps Email Extractor](https://apify.com/socialscrapers/google-maps-email-extractor) | Emails, Phones and Social Links |
| [Google Maps Scraper](https://apify.com/socialscrapers/google-maps-scraper) | Places, Phones, Websites, Ratings and Hours |
| [Google News Scraper](https://apify.com/socialscrapers/google-news-scraper) | Headlines, Articles and Search |
| [Google Ads Transparency Scraper](https://apify.com/socialscrapers/google-ads-transparency-scraper) | Ad Creatives and Advertisers |
| [Amazon Product Scraper](https://apify.com/socialscrapers/amazon-product-scraper) | Search Results, Prices, Ratings, ASINs |
| [Indeed Jobs Scraper](https://apify.com/socialscrapers/indeed-jobs-scraper) | Salaries, Full Descriptions, Company Data |
| [Contact Details Scraper](https://apify.com/socialscrapers/contact-details-scraper) | Emails, Phones and Social Links |
| [Telegram Channel Scraper](https://apify.com/socialscrapers/telegram-channel-scraper) | Posts, Views and Media |
| [Doximity Scraper](https://apify.com/socialscrapers/doximity-physician-scraper) | Physician Profiles and Doctor Directory |
| [KevinMD Scraper](https://apify.com/socialscrapers/kevinmd-articles-scraper) | Physician Articles and Author Specialties |
| [Op-Med Scraper](https://apify.com/socialscrapers/opmed-articles-scraper) | Physician Essays and Doctor Profiles |
| [Career Site Jobs Scraper](https://apify.com/socialscrapers/career-site-jobs-scraper) | Greenhouse, Lever, Ashby and Workday |
| [Google Trends Scraper](https://apify.com/socialscrapers/google-trends-scraper) | Interest Over Time, Regions and Queries |

# Actor input Schema

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

What you would type into YouTube's search box, one term per line. Each term is searched on its own. Example: <code>sourdough bread recipe</code>.

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

How many results to save for each search term. YouTube lists a few hundred results for most terms; for more, add related terms or use the upload date filter. Example: <code>200</code>.

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

What to search for, like the type filter on YouTube. "Channels" saves one channel item per channel found (subscribers, total videos and views, country, links) instead of videos.

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

The order of the search results: YouTube's relevance, or most viewed first.

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

Only videos uploaded within this period (YouTube's own search filter). For an exact range, use the date range below.

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

Only videos of this length.

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

Only videos with all of these features, as in YouTube's search filters. Example: <code>4K</code> and <code>Subtitles/CC</code>.

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

Only videos published on or after this date, or within this age. Pick a date or an age, or type one: a date (<code>2026-01-31</code>, <code>31/01/2026</code>, <code>Jan 31 2026</code>; a UTC day) or an age such as <code>7 days</code>, <code>2w</code>, <code>6 months</code> or <code>yesterday</code>. When no upload date is chosen, the tightest one that covers this date is used.

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

Only videos published on or before this date (the whole day counts), or before this age. A date (<code>2026-01-31</code>, <code>31/01/2026</code>, <code>Jan 31 2026</code>) or an age such as <code>7 days</code> or <code>1 year</code>.

## `includeComments` (type: `boolean`):

Comments are not part of this Actor.

## `downloadSubtitles` (type: `boolean`):

Subtitles are not part of this Actor.

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

Residential proxies give the most reliable results.

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

How many results are read at the same time. Example: <code>20</code>.

## Actor input object example

```json
{
  "searchQueries": [
    "sourdough bread recipe"
  ],
  "maxResultsPerQuery": 10,
  "searchType": "video",
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "includeComments": false,
  "downloadSubtitles": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  },
  "maxConcurrency": 20
}
```

# 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 = {
    "searchQueries": [
        "sourdough bread recipe"
    ],
    "maxResultsPerQuery": 10
};

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

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

```

## MCP server setup

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