# YouTube Data Scraper – Videos, Channels & Comments (`badr_xba/youtube-data-scraper`) Actor

Extract YouTube videos, channels, playlists and comments through the official YouTube Data API: views, likes, comments, duration, tags, subscribers, plus computed metrics (engagement rate, views per day, performance vs channel average).

- **URL**: https://apify.com/badr\_xba/youtube-data-scraper.md
- **Developed by:** [Badr Bouargan](https://apify.com/badr_xba) (community)
- **Categories:** Social media
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 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?

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 Data Scraper – Videos, Channels & Comments

Extract **YouTube videos, channels, playlists and comments** — views, likes, comments, duration, tags, subscribers — plus **computed metrics YouTube doesn't show**: engagement rate, views per day, likes per 1,000 views and performance versus the channel average.

> ### ▶️ No API key, no Google account
>
> Click **Try for free**, type a search or paste a channel, and run. Nothing to create, nothing to configure.

### ✨ What makes it different

| | This Actor |
|---|---|
| **Setup** | None — no API key, no quota, no Google Cloud project |
| **Computed metrics** | Engagement rate, views/day, likes per 1,000 views, performance vs channel average, Shorts detection |
| **Channel insight** | Average views over the channel's 30 latest videos — a fairer benchmark than lifetime totals |
| **Filters** | Views, likes, age, publish date, Shorts/long/live, title keywords, excluded words |
| **Resilience** | Rotating Apify Proxy, automatic retries, clear message if YouTube refuses a request |

### 🚀 Inputs

- **Search queries** — like typing in YouTube's search bar; sort by relevance, date or view count
- **Channels** — `https://www.youtube.com/@LofiGirl`, `@LofiGirl` or `UC…` → channel profile + latest videos
- **Videos** — watch URLs, Shorts, `youtu.be`, live links
- **Playlists** — `…?list=PL…`
- **Comments** — optional, top comments per video
- Filters, region, language, proxy and speed settings

### 📦 Output example (video)

```json
{
    "type": "video",
    "videoId": "HV6OlMPn5sI",
    "title": "Raimu - The Spirit Within 🍃",
    "url": "https://www.youtube.com/watch?v=HV6OlMPn5sI",
    "publishedAt": "2026-07-11T10:00:00+00:00",
    "videoAgeDays": 67,
    "duration": "29:54",
    "isShort": false,
    "viewCount": 410458,
    "likeCount": 12043,
    "commentCount": 318,
    "viewsPerDay": 6126,
    "engagementRate": 3.012,
    "likesPerThousandViews": 29.3,
    "performanceVsChannel": 1.42,
    "tags": ["lofi", "chill"],
    "hashtags": ["#lofi"],
    "category": "Music",
    "channelTitle": "Lofi Girl",
    "channelHandle": "@LofiGirl",
    "channelSubscribers": 15700000,
    "channelAverageViews": 289000,
    "thumbnailUrl": "https://i.ytimg.com/vi/HV6OlMPn5sI/maxresdefault.jpg",
    "source": "recherche : lofi hip hop"
}
```

Channels come out as `type: "channel"` (subscribers, average views of recent videos, views per subscriber, keywords) and comments as `type: "comment"` (text, author, likes, date, pinned).

### 💡 Tips

- **Faster runs**: raise *Videos read in parallel* (up to 10).
- **Some videos refused?** YouTube sometimes challenges shared IPs. Pick the **RESIDENTIAL** proxy group in *Proxy*.
- **Only channel profiles**: set *Maximum videos per source* to `0`.

### ⚖️ Legal

This Actor only reads **public** data that anyone can see on YouTube without logging in. It never logs in, never downloads video files, and collects no private data. Automated access may conflict with YouTube's Terms of Service; you are responsible for how you use the data, including compliance with GDPR and other laws when handling comment author names.

***

### 🇫🇷 En français

Extrait les **vidéos, chaînes, playlists et commentaires YouTube**, **sans clé API ni compte Google** : lancez, c'est tout. En plus des données brutes, l'Actor calcule le **taux d'engagement**, les **vues par jour**, les **likes pour 1 000 vues** et la **performance face à la moyenne des 30 dernières vidéos de la chaîne**, et détecte les **Shorts**. Filtres : vues, likes, ancienneté, date, type de vidéo, mots-clés du titre.

# Actor input Schema

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

Mots-clés comme dans la barre de recherche YouTube (ex. recette tajine, lofi hip hop).

## `channelUrls` (type: `array`):

URLs ou identifiants de chaînes : https://www.youtube.com/@LofiGirl, @LofiGirl ou UCSJ4gkVC6NrvII8umztf0Ow. Vous obtenez la fiche de la chaîne et ses dernières vidéos.

## `videoUrls` (type: `array`):

URLs ou identifiants de vidéos précises (watch, Shorts, youtu.be, live).

## `playlistUrls` (type: `array`):

URLs ou identifiants de playlists (…?list=PL…).

## `maxVideosPerSource` (type: `integer`):

S'applique à chaque recherche, chaîne et playlist. Mettez 0 pour n'avoir que la fiche des chaînes.

## `includeChannelDetails` (type: `boolean`):

Moyenne de vues des 30 dernières vidéos de la chaîne, et performance de chaque vidéo par rapport à cette moyenne.

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

Ajoute les meilleurs commentaires de chaque vidéo (texte, auteur, likes, date, épinglé).

## `maxCommentsPerVideo` (type: `integer`):

Nombre de commentaires récupérés par vidéo, les meilleurs d'abord.

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

Filtre sur la durée et le format.

## `minViews` (type: `integer`):

Ne garder que les vidéos ayant au moins ce nombre de vues.

## `minLikes` (type: `integer`):

Ne garder que les vidéos ayant au moins ce nombre de likes.

## `maxAgeDays` (type: `integer`):

Ex. 30 pour ne garder que les vidéos du dernier mois.

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

Date au format ISO, ex. 2026-01-01.

## `titleKeywords` (type: `array`):

Ne garder que les vidéos dont le titre contient un de ces mots.

## `excludeKeywords` (type: `array`):

Exclure les vidéos dont le titre contient un de ces mots.

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

Ordre des résultats pour les recherches par mots-clés.

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

Code pays à 2 lettres pour orienter les résultats (MA, FR, US…).

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

Code langue à 2 lettres pour orienter les résultats et les textes (fr, ar, en…).

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

Le proxy Apify évite que YouTube bloque les requêtes. Si des vidéos sont refusées, choisissez le groupe « RESIDENTIAL ».

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

Plus élevé = plus rapide, mais YouTube bloque plus facilement.

## Actor input object example

```json
{
  "searchQueries": [
    "lofi hip hop"
  ],
  "maxVideosPerSource": 20,
  "includeChannelDetails": true,
  "includeComments": false,
  "maxCommentsPerVideo": 20,
  "videoType": "all",
  "order": "relevance",
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "maxConcurrency": 5
}
```

# Actor output Schema

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

Tableau : titre, chaîne, vues, likes, commentaires, durée, engagement et lien.

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

Données complètes : description, tags, hashtags, statistiques de chaîne, commentaires.

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

Nombre de vidéos, chaînes, commentaires et unités de quota consommées.

# 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": [
        "lofi hip hop"
    ],
    "maxVideosPerSource": 20,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("badr_xba/youtube-data-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": ["lofi hip hop"],
    "maxVideosPerSource": 20,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("badr_xba/youtube-data-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": [
    "lofi hip hop"
  ],
  "maxVideosPerSource": 20,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call badr_xba/youtube-data-scraper --silent --output-dataset

```

## MCP server setup

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