# $3/1K | YouTube Scraper - Search, Videos & Transcripts (`scrapercompany/youtube-scraper`) Actor

Scrape YouTube search results, video details (exact views, likes, dates, chapters), transcripts with timestamps, comments with likes and reply counts, channel and playlist videos, and trending charts. Filters for type, upload date and duration; batch many inputs. Made by ScraperCompany.

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

## Pricing

from $3.00 / 1,000 youtube search pages

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 Scraper - Search, Videos, Transcripts & Comments

**YouTube Scraper** by ScraperCompany collects youtube.com data in nine modes. **Search** returns videos, Shorts, channels and playlists for a query with YouTube's type, upload-date, duration, feature and sort filters.

### ⭐ Like this Actor? Leave a review

If YouTube Scraper saved you time, please [leave a review on the Store](https://apify.com/scrapercompany/youtube-scraper/reviews). It takes a minute, helps other people find a scraper that works, and tells us what to build next.

> 🟢 **Nothing to set up:** no code, no login and no keys. Click **Try for free**, start a run, and export JSON, CSV or Excel, or pull the results through the Apify API. You pay only for results; failed and empty requests are free.

### 📦 What you get

| Mode | What you get | Price | Per 1,000 |
| --- | --- | --- | --- |
| `search` | Videos, Shorts, channels and playlists for a search, with YouTube's type, upload date, duration, feature and sort filters | $0.003 | $3.00 |
| `video` | Title, description, channel, exact views and likes, publish date, category, keywords, live flags and chapters per video | $0.004 | $4.00 |
| `transcript` | A video's captions as timed segments and joined text, in a chosen language, plus every caption language available | $0.004 | $4.00 |
| `comments` | A video's comments, Top or Newest, with likes, reply counts, pinned and creator-heart flags | $0.003 | $3.00 |
| `channel` | A channel's title, handle, audience and video counts, description, links, and its latest videos newest first | $0.003 | $3.00 |
| `playlist` | A playlist's title, channel and video count, with its videos in playlist order | $0.003 | $3.00 |
| `trending` | A country's trending music videos chart, in chart order | $0.003 | $3.00 |
| `channels` | Channels matching a search: name, handle, audience and video counts, description and link | $0.003 | $3.00 |
| `shorts` | YouTube Shorts matching a search, as Google lists them: title, channel, views, length, date, thumbnail and link | $0.003 | $3.00 |

- 💵 **Price:** from **$3 per 1,000** `search-page` events ($0.003 each); failed and empty requests are free.
- ⚙️ **Setup:** none. No account on the site, no cookies, no keys.
- 📁 **Export:** JSON, CSV, Excel or HTML from the **Output** tab, or the Apify API.
- 🔁 **Automate:** schedules, webhooks, Make, Zapier, n8n and AI agents (MCP).

### ✨ What can this YouTube scraper do?

**Video details** returns the **title, full description, channel, exact view and like counts, publish date, category, keywords, live flags and chapters**. **Transcript** returns a video's captions as **timed segments** and joined text, in any language the video has. **Comments** returns comment threads (Top or Newest) with **likes, reply counts, pinned and creator-heart flags**. **Channel videos** returns a channel's metadata and its latest videos, **Playlist videos** a playlist's videos in order, and **Trending** a country's trending music videos chart. Pricing is pay-per-event: **$0.003 per search, comments, channel, playlist or trending page and $0.004 per video or transcript**; failed requests and empty pages are not charged.

- **Search** with type, upload date, duration, features (subtitles, 4K, live, Creative Commons...) and sort filters, up to 20 pages per query.
- **Video details**: exact views and likes, ISO publish and upload dates, category, keywords, hashtags, thumbnails and chapters.
- **Transcripts** as timed segments plus plain text, with the list of caption languages; pick a language or take the default track.
- **Channel search** by keyword, and **Shorts search** with title, channel, views, length and link, at the search-page price.
- **Comments**: Top or Newest, author, likes, reply count, pinned and hearted flags, and a token to read each thread's replies.
- **Channel videos**: title, handle, audience and video counts as YouTube shows them, description, links, and the latest videos newest first, up to 50 pages.
- **Playlist videos**: the playlist's title, channel and video count, then its videos in playlist order, up to 50 pages.
- **Trending**: one country's trending music videos chart in chart order, with title, channel, views and length.
- Accepts video ids or any video link, channel handles, ids or links, and playlist ids or links. Batch many inputs; empty answers are free.

### 🚀 Quick start: how to scrape YouTube videos, transcripts and comments

1. Click **Try for free** (or open the Actor in Apify Console) and go to the **Input** tab.
2. Pick a **Mode**. For Search enter queries; for Video details, Transcript or Comments paste video ids or links; for Channel videos enter handles such as `@NASA`; for Playlist videos paste playlist ids or links; for Trending enter country codes such as `US`. Raise **Pages per query, video, channel or playlist** for more results.
3. Adjust the options if needed.
4. Click **Start** and wait for the run to finish.
5. Download the results from the **Output** tab as JSON, CSV, Excel or HTML, or fetch them with the Apify API.

💡 **Tip:** run it once with the pre-filled input to see the output, then change the input to your own.

### ⚖️ What makes it different?

| | **YouTube Scraper** | Many alternatives |
| --- | --- | --- |
| Setup | Nothing to configure: no login, no keys | Often your own accounts, cookies or network setup |
| You pay for | Successful results; failed and empty requests are free | Often run time, or every attempt |
| When a request fails | Retried automatically, and never charged | Often an empty or failed run |

### 👥 Who uses YouTube data?

- **Marketers and creators**: Track which videos rank for your keywords and how fast their views grow.
- **AI and research teams**: Collect transcripts as timed segments or plain text for summaries, search and training data.
- **Brands**: Read what viewers say in the comments of your videos and your competitors'.

### 🧭 Common jobs

#### Research a topic

Run **Search** with upload-date and duration filters, then **Video details** on the results for exact views and likes.

#### Turn videos into text

Run **Transcript** to get timed captions for summaries, search or feeding a model.

#### Read the audience

Run comments on a video to collect what viewers say about it.

#### Track the charts

Run **Trending** on several countries each day to see which music videos rise.

### 📋 What YouTube data can you extract?

| Field | Description |
| --- | --- |
| `videos[].video_id / title / link / channel` | Search and channel result rows |
| `videos[].views / views_text / length_seconds / published_time` | Counts, length and age as YouTube shows them |
| `shorts[] / channels[] / playlists[]` | Other result kinds (Search) |
| `video.views / likes / published_date / category / chapters` | Video details |
| `segments[].start_s / duration_s / text, text` | Transcript (timed and joined) |
| `available_languages[]` | Caption languages of the video |
| `comments[].text / author / likes / reply_count / is_pinned` | Comments |
| `channel.title / handle / video_count_text / description / links` | Channel metadata (Channel videos) |
| `playlist.title / channel / video_count_text` | Playlist header (Playlist videos) |
| `chart, videos[].position` | Chart name and rank (Trending) |
| `next_page_token` | Token for the next page |

Every dataset item also carries `input` (the options used for that request), `request_id` (quote it to support), `billed` and `scraped_at`.

### ⌨️ Input

| Input | Name | What it does |
| --- | --- | --- |
| `mode` | Mode | Search YouTube by keyword, read details, transcripts or comments of known videos, list a channel's latest videos or a playlist's videos, read a country's trending chart, find channels by keyword, or search Shorts. |
| `queries` | Search queries (Search, Channel search, Shorts search) | One YouTube search per line, as typed in YouTube's search box. |
| `videoIds` | Videos (Video details, Transcript, Comments) | ?.be/`, `/shorts/`, `/live/`). |
| `channels` | Channels (Channel videos) | ...` channel id or a channel link. |
| `playlists` | Playlists (Playlist videos) | One playlist per line: its id (`PLBCF2DAC6FFB574DE`) or any link with `list=`. |
| `countries` | Countries (Trending) | One two-letter country code per line, such as `US`, `GB` or `IN`. Each country is one trending chart. |
| `maxPages` | Pages per query, video, channel or playlist | How many pages to fetch for each search (up to 20), video's comments, channel's videos or playlist (up to 50). |
| `type` | Result type (Search) | Only one kind of result. Leave empty for YouTube's mixed page. |
| `upload_date` | Upload date (Search) | Only videos uploaded within this period. |
| `duration` | Duration (Search) | YouTube's length buckets. |
| `features` | Features (Search) | YouTube's Features filters, combined: `hd`, `subtitles`, `creative_commons`, `3d`, `live`, `purchased`, `4k`, `360`, `location`, `hdr`, `vr180`. |
| `searchSort` | Sort (Search) | Relevance (YouTube's default) or most viewed first. |
| `commentSort` | Sort (Comments) | YouTube's comment order: Top comments (default) or Newest first. |
| `lang` | Caption language (Transcript) | Language code such as `en`, `es` or `pt-BR`. Creator captions win over auto-generated ones. |
| `hl` | Interface language | .g. `en`, `de`. Counts are parsed to numbers for English-style formats only. |
| `gl` | Country | .g. `US`, `GB`, `IN`. |

### 📥 Input example

This is the default input; running the Actor without changes uses it.

```json
{
  "mode": "search",
  "queries": [
    "sourdough bread recipe"
  ],
  "videoIds": [
    "arj7oStGLkU"
  ],
  "channels": [
    "@NASA"
  ],
  "playlists": [
    "PLBCF2DAC6FFB574DE"
  ],
  "countries": [
    "US"
  ],
  "maxPages": 1,
  "includeErrors": true,
  "maxConcurrency": 3,
  "maxRetries": 2
}
```

### 📤 Output example

One dataset item per request (trimmed here; real items contain all the fields):

```json
{
  "mode": "search",
  "input": {
    "q": "python tutorial"
  },
  "meta": {
    "source": "youtube"
  },
  "next_page_token": "EroDEg9weXRob24gdHV0b3JpYWwapgNTQlNDQVF0cGVE…",
  "playlists": [
    {
      "channel": {
        "handle": "@shradhaKD",
        "id": "UC1XBh-m27kkgwLAwu_SRJBg",
        "link": "https://www.youtube.com/@shradhaKD",
        "name": "Shradha Khapra",
        "verified": false
      },
      "first_video_id": "t2_Q2BRzeEE",
      "kind": "course",
      "label": "Course",
      "link": "https://www.youtube.com/playlist?list=PLGjplNEQ1it8-0CmoljS5yeV-GlKSUEt0",
      "playlist_id": "PLGjplNEQ1it8-0CmoljS5yeV-GlKSUEt0",
      "position": 1,
      "thumbnail": "https://i.ytimg.com/vi/t2_Q2BRzeEE/hq720.jpg?sqp=-oaymwEXCNAFEJQDSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLBm5_nQyrAnm5zyJ2FBA9l3BKyzMA",
      "title": "Python Language Full Course (2026)",
      "video_count_text": "9 lessons"
    }
  ],
  "search_information": {
    "estimated_results": 11103091,
    "total": 4
  },
  "search_parameters": {
    "gl": "US",
    "hl": "en",
    "q": "python tutorial"
  },
  "shorts": [
    {
      "link": "https://www.youtube.com/shorts/nluUYtejoIE",
      "position": 1,
      "thumbnail": "https://i.ytimg.com/vi/nluUYtejoIE/oar2.jpg?sqp=-oaymwEoCJUDENAFSFqQAgHyq4qpAxcIARUAAIhC2AEB4gEKCBgQAhgGOAFAAQ==&rs=AOn4CLCuNV89Mvv4RG_YBfH0wDDrB1zpPg&usqp=CCk",
      "title": "Python Basics: Your FIRST Program in Under a Minute! 🚀",
      "video_id": "nluUYtejoIE",
      "views_text": "1.7M views"
    }
  ],
  "skipped_items": {},
  "videos": [
    {
      "badges": [
        "Fundraiser"
      ],
      "channel": {
        "handle": "@BroCodez",
        "id": "UC4SVo0Ue36XCfOyb5Lh1viQ",
        "link": "https://www.youtube.com/@BroCodez",
        "name": "Bro Code",
        "thumbnail": "https://yt3.ggpht.com/ytc/AIdro_mPFVsxROj1dOtTWc9iNBwDYV4z42Q8LPokBSewiW9pCSg=s68-c-k-c0x00ffffff-no-rj",
        "verified": true
      },
      "description": "python #tutorial #beginners Python tutorial for beginners' full course 2024 *Learn Python in 1 HOUR* ...",
      "is_live": false,
      "length": "12:00:00",
      "length_seconds": 43200,
      "link": "https://www.youtube.com/watch?v=ix9cRaBkVe0",
      "position": 1,
      "published_time": "2 years ago",
      "thumbnail": "https://i.ytimg.com/vi/ix9cRaBkVe0/hq720.jpg?sqp=-oaymwEnCNAFEJQDSFryq4qpAxkIARUAAIhCGAHYAQHiAQoIGBACGAY4AUAB&rs=AOn4CLDsLPZCX5PFS2a-Wng9IwGAduPqOQ",
      "title": "Python Full Course for free 🐍",
      "video_id": "ix9cRaBkVe0",
      "views": 12753881,
      "views_text": "12,753,881 views"
    }
  ],
  "request_id": "req_3f9c0d6e2b8a4c1f9e7d5b3a1c0e8f6d",
  "billed": true,
  "scraped_at": "2026-10-01T14:03:27.512Z"
}
```

A request that fails is saved with an `error` message instead (turn off **Include failed requests** to skip those). Failed requests are never charged.

### 💰 How much does it cost to scrape YouTube videos, transcripts and comments?

This Actor uses **pay-per-event** pricing: you pay for successful requests, not for compute time.

| Event | Charged when | Price | Per 1,000 |
| --- | --- | --- | --- |
| `search-page` | One page of YouTube search results (about 20 videos, Shorts, channels and playlists). Empty pages are free. | $0.003 | $3.00 |
| `video` | One video's metadata: title, description, channel, exact views and likes, dates, category, keywords, chapters. | $0.004 | $4.00 |
| `transcript` | One video's caption track as timed segments plus the joined text. Videos without captions are free. | $0.004 | $4.00 |
| `comments-page` | One page of a video's comments (about 20 threads). Empty pages and videos with comments turned off are free. | $0.003 | $3.00 |
| `channel-page` | A channel's metadata with its latest videos (about 30 per page). Empty later pages are free. | $0.003 | $3.00 |
| `playlist-page` | One page of a playlist (its title, channel and video count, with up to about 100 videos in playlist order). Empty pages are free. | $0.003 | $3.00 |
| `trending-page` | One country's trending music videos chart, in chart order, with title, channel, views and length. An empty chart is free. | $0.003 | $3.00 |

The **$3/1K** in the title is the price of 1,000 `search-page` events, the cheapest mode; the table above prices every mode.

🏷️ Paid Apify plans pay less: `transcript` up to 10% off (Bronze 5%, more on higher plans). The Pricing tab shows the price on your plan.

#### Cost examples

| Job | Cost |
| --- | --- |
| 20 searches | **$0.06** |
| Details and transcripts for 500 videos | **$4.00** |
| 10 playlists and 10 trending charts | **$0.06** |

Apify's $5 of free monthly usage covers about **1,666** `search-page` events.

- ✅ Failed requests (errors, invalid input, a site refusing after retries) are **free**.
- ✅ Requests where the source returns nothing at all (no results, nothing priced) are saved but **not charged**.
- ✅ Set **Maximum cost per run** when you start a run and the Actor stops cleanly before going over it.

### 🔌 Integrations

#### ⏰ Schedules and webhooks

Use Apify **Schedules** to repeat a run hourly, daily or weekly and compare results over time, and **webhooks** or the **Integrations** tab to push new results to Make, Zapier, n8n, Google Sheets, Slack or your own warehouse.

#### 🤖 AI agents and MCP

Results are structured JSON, so they are easy to feed to a model. AI agents such as Claude can run this Actor and read its results through the [Apify MCP server](https://mcp.apify.com).

#### 💻 API: JavaScript and Python

Call the Actor from any language through the [Apify API](https://docs.apify.com/api/v2). With the JavaScript client (`npm install apify-client`):

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

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('scrapercompany/youtube-scraper').call({
    "mode": "search",
    "queries": [
        "sourdough bread recipe"
    ]
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

With Python (`pip install apify-client`):

```python
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("scrapercompany/youtube-scraper").call(run_input={
    "mode": "search",
    "queries": ["sourdough bread recipe"],
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

### ❓ FAQ

#### Do I need an account on the site, or an API key?

No. The Actor is ready to run as is, and you only pay the per-event prices above.

#### Do I need a YouTube account or API key?

No. The Actor reads public YouTube pages without logging in and without a YouTube Data API key or quota.

#### Why are some view counts empty?

YouTube shows some counts only in rounded form ("61K views"). The rounded text is always in `views_text`; `views` is filled when YouTube shows the exact number.

#### What if a video has no captions?

The Transcript request fails with a clear message and is not charged. A language the video has no captions in also fails free and lists the languages it has.

#### Is it legal to scrape YouTube videos, transcripts and comments?

The Actor collects publicly available information that anyone can see without logging in. You are responsible for how you use the results: respect the source site's terms, copyright and privacy law (such as GDPR) and do not collect personal data without a lawful basis. If in doubt, ask a lawyer.

#### What happens when a request fails?

Failed attempts are retried automatically. If a request still fails it is saved with the error message and not charged, and the rest of the batch keeps going. A run only fails when every request failed.

#### Why did a request return an error?

Read the `error` field: it says what was wrong with the input, for example a malformed date or an unknown id. Fix it and run again; failed requests cost nothing.

#### How many requests can I run at once?

Any number per run. The Actor sends up to 3 requests in parallel by default (change it under **Run options**); larger batches simply take longer.

### 🔗 Related scrapers

- [Google Videos Scraper](https://apify.com/scrapercompany/google-videos-scraper): video results from Google Search across sites
- [Google SERP Scraper](https://apify.com/scrapercompany/google-search-scraper): regular Google results

### 📝 Tried it? Tell others

Once you have run YouTube Scraper, a [short review on the Store](https://apify.com/scrapercompany/youtube-scraper/reviews) helps the next person decide.

### 💬 Support

Questions, a field you need, or a site that stopped working? Open an issue on the **Issues** tab. Include the `request_id` from the dataset item so we can trace the request. We read every issue.

# Changelog

This Actor's version history is a separate document: https://apify.com/scrapercompany/youtube-scraper/changelog.md

# Actor input Schema

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

Search YouTube by keyword, read details, transcripts or comments of known videos, list a channel's latest videos or a playlist's videos, read a country's trending chart, find channels by keyword, or search Shorts.

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

One YouTube search per line, as typed in YouTube's search box.

## `videoIds` (type: `array`):

One video per line: the 11-character id (<code>arj7oStGLkU</code>) or any YouTube video link (<code>watch?v=</code>, <code>youtu.be/</code>, <code>/shorts/</code>, <code>/live/</code>).

## `channels` (type: `array`):

One channel per line: an <code>@handle</code>, a <code>UC...</code> channel id or a channel link.

## `playlists` (type: `array`):

One playlist per line: its id (<code>PLBCF2DAC6FFB574DE</code>) or any link with <code>list=</code>.

## `countries` (type: `array`):

One two-letter country code per line, such as <code>US</code>, <code>GB</code> or <code>IN</code>. Each country is one trending chart.

## `maxPages` (type: `integer`):

How many pages to fetch for each search (up to 20), video's comments, channel's videos or playlist (up to 50). Each page is a separate request and is charged separately; paging stops when YouTube has no further page.

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

Only one kind of result. Leave empty for YouTube's mixed page.

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

Only videos uploaded within this period.

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

YouTube's length buckets.

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

YouTube's Features filters, combined: <code>hd</code>, <code>subtitles</code>, <code>creative_commons</code>, <code>3d</code>, <code>live</code>, <code>purchased</code>, <code>4k</code>, <code>360</code>, <code>location</code>, <code>hdr</code>, <code>vr180</code>.

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

Relevance (YouTube's default) or most viewed first.

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

YouTube's comment order: Top comments (default) or Newest first.

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

Language code such as <code>en</code>, <code>es</code> or <code>pt-BR</code>. Creator captions win over auto-generated ones. Leave empty for English when the video has it, else the video's default track. A language the video has no captions in fails (free) and lists the languages it has.

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

Language YouTube writes relative dates and view counts in, e.g. <code>en</code>, <code>de</code>. Counts are parsed to numbers for English-style formats only.

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

Two-letter country code for YouTube content and rankings, e.g. <code>US</code>, <code>GB</code>, <code>IN</code>.

## `customRequests` (type: `array`):

Optional list of JSON objects, one request each, using the field names shown above. Each object is merged over the options above, so you only need to give what differs. Add <code>"mode"</code> to an object to mix modes; a comment thread's <code>replies_page_token</code> with mode <code>comments</code> reads its replies. Example: <code>{"mode":"search","q":"marathon training","type":"video","duration":"long"}</code>

## `includeErrors` (type: `boolean`):

When on, a request that fails (for example an unknown property id) is saved as a dataset item with an <code>error</code> message so you can see what went wrong. Failed requests are never charged.

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

How many requests run at the same time (1-8). Parallel runs share one limit, so extra requests wait for a free slot instead of failing.

## `maxRetries` (type: `integer`):

How many times a request that failed for a temporary reason is tried again right away. A request still failing then gets one more try at the end of the run, after a 30-second pause. Invalid input is never retried.

## Actor input object example

```json
{
  "mode": "search",
  "queries": [
    "sourdough bread recipe"
  ],
  "videoIds": [
    "arj7oStGLkU"
  ],
  "channels": [
    "@NASA"
  ],
  "playlists": [
    "PLBCF2DAC6FFB574DE"
  ],
  "countries": [
    "US"
  ],
  "maxPages": 1,
  "commentSort": "top",
  "hl": "en",
  "gl": "US",
  "includeErrors": true,
  "maxConcurrency": 3,
  "maxRetries": 2
}
```

# Actor output Schema

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

One dataset item per request.

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

Counts of succeeded, failed, skipped and charged requests.

# 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": [
        "sourdough bread recipe"
    ],
    "videoIds": [
        "arj7oStGLkU"
    ],
    "channels": [
        "@NASA"
    ],
    "playlists": [
        "PLBCF2DAC6FFB574DE"
    ],
    "countries": [
        "US"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapercompany/youtube-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": ["sourdough bread recipe"],
    "videoIds": ["arj7oStGLkU"],
    "channels": ["@NASA"],
    "playlists": ["PLBCF2DAC6FFB574DE"],
    "countries": ["US"],
}

# Run the Actor and wait for it to finish
run = client.actor("scrapercompany/youtube-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": [
    "sourdough bread recipe"
  ],
  "videoIds": [
    "arj7oStGLkU"
  ],
  "channels": [
    "@NASA"
  ],
  "playlists": [
    "PLBCF2DAC6FFB574DE"
  ],
  "countries": [
    "US"
  ]
}' |
apify call scrapercompany/youtube-scraper --silent --output-dataset

```

## MCP server setup

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