# YouTube Video Scraper (`amats-core/youtube-scraper`) Actor

Collect public YouTube videos in a few clicks. Search by keyword, collect a channel, paste YouTube URLs, or get Trending. Results include title, description, channel, views, likes, duration, thumbnail, and publish time.

- **URL**: https://apify.com/amats-core/youtube-scraper.md
- **Developed by:** [Amats Core](https://apify.com/amats-core) (community)
- **Categories:** Videos, Developer tools, Automation
- **Stats:** 2 total users, 1 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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

<p align="center">
  <img src="https://raw.githubusercontent.com/amats-core/assets/main/banner.png" alt="Amats Core" width="100%">
</p>

## YouTube Video Scraper

**by Amats Core**

Collect public YouTube videos in a few clicks. Search by keyword, collect a channel, paste YouTube URLs, or get Trending. Results include title, description, channel, views, likes, duration, thumbnail, and publish time.

You do not need a YouTube login. Fill in the form and start the run.

***

### What you get

- **Search by keyword** — enter one or more topics. Optional date, duration, feature, and sort filters.
- **Channels** — paste a handle such as `@yourchannel` or a channel URL. Optionally include Shorts.
- **URLs** — videos, Shorts, playlists, channels, and search result pages.
- **Trending** — collect videos from YouTube Trending.
- **Metadata only** — title, description, stats, and thumbnail. This actor does not download video files.

***

### How to run

1. Choose **Search by keywords**, **Channel**, **YouTube URLs**, or **Trending**.
2. Fill in that section only.
3. Set how many videos you want.
4. For keyword search (or a search URL), filters are optional. Leave the defaults if you do not need them. Channel, Trending, and other URLs ignore those search filters.
5. Click **Start**.

#### Search example

```json
{
  "mode": "search",
  "keywords": ["coffee", "travel"],
  "maxItems": 20
}
```

#### Channel example

```json
{
  "mode": "channel",
  "youtubeHandles": ["@yourchannel"],
  "includeShorts": false,
  "maxItems": 10
}
```

#### URL example

```json
{
  "mode": "urls",
  "startUrls": [
    "https://www.youtube.com/results?search_query=travel"
  ],
  "maxItems": 20
}
```

#### Trending example

```json
{
  "mode": "trending",
  "maxItems": 20
}
```

***

### Input fields

| Field | What it means |
|---|---|
| **What do you want to collect?** | Search by keywords, Channel, YouTube URLs, or Trending. |
| **Keywords** | Topics to search for. Used in search mode. |
| **Channel handles** | Public handles such as `@yourchannel`. Used in channel mode. |
| **Include Shorts** | Also collect Shorts from the channel. |
| **YouTube URLs** | Video, channel, playlist, Shorts, or search URLs. Used in URL mode. |
| **Number of videos** | Maximum videos to collect (1–10000). Default is 20. |
| **Country / Language** | YouTube country and language, for example `us` and `en`. Used in every mode. |
| **Upload date, Duration, Features, Sort by** | Optional. **Search by keywords** and search result URLs only. Ignored for Channel, Trending, video URLs, playlists, and channel URLs. |

***

### Output

Each video is one row in the dataset.

| Field | What it is |
|---|---|
| `id` | Video ID |
| `url` | Link to the video |
| `title` | Video title |
| `description` | Video description |
| `duration` | Length in seconds |
| `views` | View count |
| `likes` | Like count |
| `channel.id` | Channel ID |
| `channel.name` | Channel name |
| `channel.url` | Channel link |
| `channel.avatarUrl` | Channel photo |
| `thumbnailUrl` | Thumbnail image |
| `publishedAt` | Publish time (ISO 8601) |

***

### Sample result

```json
{
  "id": "exampleVid01",
  "url": "https://www.youtube.com/watch?v=exampleVid01",
  "title": "How we brew coffee at home",
  "description": "A short walkthrough of our weekend coffee routine.",
  "publishedAt": "2024-06-15T10:00:00.000Z",
  "duration": 212,
  "views": 12840,
  "likes": 342,
  "channel": {
    "id": "UCxxxxxxxxxxxxxxxxxxxxxx",
    "name": "Example Channel",
    "url": "https://www.youtube.com/channel/UCxxxxxxxxxxxxxxxxxxxxxx",
    "avatarUrl": "https://example.com/avatar.jpg"
  },
  "thumbnailUrl": "https://example.com/thumbnail.jpg"
}
```

***

### Notes

- Only **public** videos are collected. Private, members-only, and login-walled videos are not available.
- This actor does not download video files or playback URLs.
- If likes is 0, that is the public count, not a missing field.
- Very large runs take longer because each video is opened for full metadata. Start with 20–50 videos to confirm the results look right.

***

### Cost

This actor is **pay per result**. You pay a fixed price for each video collected — not for Apify compute.

Current store price: **$0.50 per 1,000 videos**. A 20-video run is charged for 20 results only. Runs that return 0 videos are not charged for results.

***

### Support

Questions or custom needs: contact **Amats Core** through the Apify platform.

# Actor input Schema

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

Search public videos by keyword, collect a channel, paste YouTube URLs, or get Trending.

## `keywords` (type: `array`):

Topics to search for. Each keyword is searched in order until the video limit is reached. Used only for “Search by keywords”. Example: coffee, travel.

## `youtubeHandles` (type: `array`):

Public channel handles, one per line. Used only for “Channel”. Example: @yourchannel

## `includeShorts` (type: `boolean`):

Used only for “Channel”. Also collect Shorts from the channel.

## `startUrls` (type: `array`):

Video, channel, playlist, Shorts, or search result links. Used only for “YouTube URLs”. Search filters apply only if the URL is a search page. Example: https://www.youtube.com/results?search\_query=travel

## `maxItems` (type: `integer`):

Maximum number of videos to collect. For search, this is the total across all keywords.

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

Two-letter country code such as us, gb, or id. Used in every mode.

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

Language code such as en, id, or es. Used in every mode.

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

Only for “Search by keywords” and search result URLs. Ignored for Channel, Trending, video URLs, playlists, and channel URLs. Leave as Any if you do not want a date filter.

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

Only for “Search by keywords” and search result URLs. Short is under about 4 minutes. Long is over about 20 minutes. Ignored for Channel, Trending, and other URL types.

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

Only for “Search by keywords” and search result URLs. Leave as Any if you do not need a feature filter. Ignored for Channel, Trending, and other URL types.

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

Only for “Search by keywords” and search result URLs. Ignored for Channel, Trending, and other URL types.

## Actor input object example

```json
{
  "mode": "search",
  "keywords": [
    "coffee",
    "travel"
  ],
  "youtubeHandles": [
    "@yourchannel"
  ],
  "includeShorts": false,
  "startUrls": [
    "https://www.youtube.com/results?search_query=travel"
  ],
  "maxItems": 20,
  "gl": "us",
  "hl": "en",
  "uploadDate": "all",
  "duration": "all",
  "features": "all",
  "sort": "r"
}
```

# Actor output Schema

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

Each item is one public YouTube video, including title, description, channel, views, likes, duration, thumbnail, and publish time.

# 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 = {
    "keywords": [
        "coffee",
        "travel"
    ],
    "youtubeHandles": [
        "@yourchannel"
    ],
    "startUrls": [
        "https://www.youtube.com/results?search_query=travel"
    ],
    "maxItems": 20,
    "gl": "us",
    "hl": "en"
};

// Run the Actor and wait for it to finish
const run = await client.actor("amats-core/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 = {
    "keywords": [
        "coffee",
        "travel",
    ],
    "youtubeHandles": ["@yourchannel"],
    "startUrls": ["https://www.youtube.com/results?search_query=travel"],
    "maxItems": 20,
    "gl": "us",
    "hl": "en",
}

# Run the Actor and wait for it to finish
run = client.actor("amats-core/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 '{
  "keywords": [
    "coffee",
    "travel"
  ],
  "youtubeHandles": [
    "@yourchannel"
  ],
  "startUrls": [
    "https://www.youtube.com/results?search_query=travel"
  ],
  "maxItems": 20,
  "gl": "us",
  "hl": "en"
}' |
apify call amats-core/youtube-scraper --silent --output-dataset

```

## MCP server setup

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