# YouTube Video Data Scraper (`googleapi/youtube-video-data-scraper`) Actor

Extract rich public YouTube video and channel metadata, including descriptions, engagement labels, chapters, thumbnails, captions, availability signals, and bounded related-video cards when exposed.

- **URL**: https://apify.com/googleapi/youtube-video-data-scraper.md
- **Developed by:** [Google API](https://apify.com/googleapi) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

Collect public metadata from YouTube videos. Provide video URLs or IDs, or use a YouTube search query to find videos. Each dataset record represents one video.

### Input

- **videoUrls**: Public YouTube watch, Shorts, live, embed, or youtu.be links, or 11-character video IDs.
- **startUrls**: Public video or search URLs.
- **query / queries**: Public YouTube search phrases. Each query reads its first results page.
- **maxItems**: Maximum valid video records; defaults to 10.
- **page / maxPages**: Search continuation pages are not supported; only the first search page is read.
- **proxyConfiguration**: Optional Apify Proxy settings for public requests.
- **sourceMode**: `public_watch` (default) preserves the original public player/watch-page scraper, including its access-boundary behavior; that public route is not retried or bypassed. `youtube_data_api` is a separate, default-off adapter backed by the YouTube Data API `videos.list` (`part=snippet,statistics,contentDetails`).

Example input:

```json
{
  "videoUrls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
  "maxItems": 1
}
```

### Dataset

Each record includes `videoId`, `title`, `videoUrl`, and `canonicalUrl`. Other fields can include:

- **Channel**: Name, ID, handle, URL, profile images, verification badge, and subscriber counts.
- **Description**: Complete public description, snippet, character count, links, and formatted HTML.
- **Engagement and duration**: Views, likes, comments, live-viewer counts, duration, and source labels. Live viewers are separate from lifetime views.
- **Dates and status**: Publication and upload dates, relative date text, live times, category, language, playability, and explicit public status flags.
- **Availability and captions**: Available countries, caption availability, languages, and public caption track metadata.
- **Additional details**: Keywords, hashtags, chapters, related video cards, license, and music credits when exposed.

Counts and flags appear only when YouTube provides them. Abbreviated counts are marked approximate; relative dates are not converted into estimated timestamps.

Example output record (selected source-backed fields; counts change over time):

```json
{
  "videoId": "jNQXAC9IVRw",
  "title": "Me at the zoo",
  "videoUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "canonicalUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "channelName": "jawed",
  "descriptionLength": 264,
  "durationSeconds": 19,
  "viewCount": 448689390,
  "likeCount": 20139722,
  "relativeDateText": "21y ago"
}
```

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

### Authorized API mode (default-off)

`sourceMode: "youtube_data_api"` uses exactly one bounded `videos.list` request for explicit video IDs. It consumes only the `snippet`, `statistics`, and `contentDetails` parts: the complete returned description (never a 500-character snippet), source-backed chapters and links, source-only tags, exact statistics, and a comment count only when the API returns one. Player-only fields (playability, captions, live state, category, subscriber/verification signals, related cards) are omitted rather than synthesized, and no video/audio download field is ever produced. When the credential is absent, the run emits zero dataset rows and makes zero API requests (`API_AUTHORIZATION_PENDING`).

Credential mechanism (exactly one): a **protected environment secret** named `APIFY_SECRET_YOUTUBE_DATA_API_KEY` (plain `YOUTUBE_DATA_API_KEY` fallback), supplied as a protected Apify environment secret — never as an input field. The key is attached only as the `X-Goog-Api-Key` request header, never placed in a URL, dataset row, log line, diagnostic, or Key-Value Store record. `apify@3.7.2` has no `Actor.getSecret()`. This independent Actor is not affiliated with YouTube or Google; API mode requires your own authorized project, credential, quota, and data-use review.

Billing/quota prerequisite: even with a configured key, the adapter stops **before the first request** unless the protected environment variable `YOUTUBE_DATA_API_BILLING_CONFIRMED` is set to the exact string `true` (operator attestation that the authorized project has the YouTube Data API enabled, billing attached and quota available). A missing or unconfirmed attestation emits zero dataset rows and writes `API_AUTHORIZATION_PENDING` with reason `billing_quota_prerequisite_missing`; it never retries or falls back to the public watch page. Provider-issued quota/billing refusals (`403`/`429` with an allowlisted reason) are likewise terminal stops with no identical retry. Public `sourceMode` never reads this variable.

### Results and limits

maxItems applies across direct videos and search results. Search sources read one initial results page each; later pages are not loaded.

Run output provides a dataset link, output totals, and run health information.

### Responsible use

This Actor reads public YouTube video information. Follow YouTube's terms, applicable law, and your data-protection obligations. This independent Actor is not affiliated with or endorsed by YouTube or Google.

# Changelog

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

# Actor input Schema

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

Default public_watch preserves the original public player/watch-page scraper unchanged (including its access-boundary behavior, which is not retried). youtube_data_api is a separate, default-off adapter backed by the YouTube Data API videos.list (parts snippet, statistics, contentDetails); it requires the protected APIFY_SECRET_YOUTUBE_DATA_API_KEY environment secret (plain YOUTUBE_DATA_API_KEY fallback) and emits zero rows with zero API requests when that credential is absent. The key is never an input field and is never written to the dataset, logs, diagnostics, or Key-Value Store. apify 3.7.2 has no Actor.getSecret().

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

Public HTTPS YouTube watch, Shorts, embed, live, or youtu.be URLs, or 11-character video IDs.

## `urls` (type: `array`):

Compatibility alias for videoUrls.

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

One public HTTPS YouTube video URL or 11-character video ID.

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

Public YouTube video URLs or YouTube search-result URLs. Other hosts and page types are ignored and logged.

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

Fetch one public YouTube search page, then enrich exposed video IDs from their public watch pages.

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

Compatibility alias for running several bounded public search pages.

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

Global maximum number of valid public video records to emit across all inputs.

## `page` (type: `integer`):

Fixed at page 1. YouTube continuation pagination is not supported; each query reads its first public search-results page only.

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

Fixed at one page per query. The Actor does not synthesize continuation tokens or claim multi-page search coverage.

## `requestDelayMs` (type: `integer`):

Respectful delay before each public search or watch-page request.

## `maxRequestRetries` (type: `integer`):

Maximum retries after a network failure. Access boundaries are not bypassed.

## `requestTimeoutSecs` (type: `integer`):

Maximum wait for one public HTML response.

## `maxResponseBytes` (type: `integer`):

Responses larger than this limit are stopped rather than truncated into misleading partial JSON.

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

Optional Apify Proxy configuration for public YouTube search-result and watch-page requests. When enabled, each request uses a generated proxy route; proxy use does not bypass access controls.

## Actor input object example

```json
{
  "sourceMode": "public_watch",
  "maxItems": 10,
  "page": 1,
  "maxPages": 1,
  "requestDelayMs": 250,
  "maxRequestRetries": 1,
  "requestTimeoutSecs": 30,
  "maxResponseBytes": 5000000
}
```

# Actor output Schema

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

No description

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

No description

## `runHealth` (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 = {};

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

# Run the Actor and wait for it to finish
run = client.actor("googleapi/youtube-video-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 '{}' |
apify call googleapi/youtube-video-data-scraper --silent --output-dataset

```

## MCP server setup

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