# YouTube Video Content Gap Analysis Scraper (`googleapi/youtube-content-gap-analysis-scraper`) Actor

Collect public video records from YouTube channel Videos pages or search results and save transparent cross-source topic comparisons separately from the dataset.

- **URL**: https://apify.com/googleapi/youtube-content-gap-analysis-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

### What this Actor does

YouTube Video Content Gap Analysis Scraper collects public video cards from channel Videos pages or YouTube search results, then compares topics found across the supplied sources. The dataset contains one row per video. The run output contains shared topics and candidate topics that appear in one sample but not another.

A candidate topic missing from a sample is only an observation about those sampled videos. It is not evidence of audience demand, popularity, ranking, or private channel performance.

### Input

Provide public channel URLs in `channelUrls` or `startUrls`, or handles in `channelHandles`. You can also use YouTube search URLs or `queries`; direct video URLs are not supported. `maxItems` caps rows across the run, and `maxVideosPerSource` limits cards collected from each source.

```json
{"channelUrl":"https://www.youtube.com/@ExampleCreator","maxItems":25,"maxVideosPerSource":10}
```

```json
{"queries":["creative technology tutorials"],"maxItems":20,"maxVideosPerSource":10,"includeHashtags":true}
```

You can combine channel and search sources in one run. `deduplicate` removes repeated video IDs, while `includeMedia`, `includeLinks`, and `includeHashtags` control optional image, channel-link, and hashtag fields.

```json
{
  "startUrls": [
    {"url":"https://www.youtube.com/@ExampleCreator"},
    {"url":"https://www.youtube.com/results?search_query=creative+technology"}
  ],
  "maxItems": 30,
  "maxVideosPerSource": 10
}
```

Use `channelUrls` to sample several public channels:

```json
{"channelUrls":["https://www.youtube.com/@NASA","https://www.youtube.com/@SpaceX"],"maxItems":4,"maxVideosPerSource":2}
```

Or supply handles without a full URL (the `@` prefix is optional):

```json
{"channelHandles":["NASA","SpaceX"],"maxItems":20,"maxVideosPerSource":10}
```

The Actor reads the first public response for each source. It does not load continuation pages or fetch individual video pages.

### Dataset output

Each video row includes `videoId`, `videoUrl`, `title`, description snippet, duration, displayed and approximate view counts, publication text, thumbnails, badges, hashtags, live/upcoming/premiere signals, and a nested `channel` object when available.

```json
{
  "videoId": "a1B2c3D4e5F",
  "videoUrl": "https://www.youtube.com/watch?v=a1B2c3D4e5F",
  "title": "Creative tools explained #creative",
  "descriptionSnippet": "A public description excerpt.",
  "durationText": "12:34",
  "viewCountText": "1.2M views",
  "viewCountEstimate": 1200000,
  "viewCountIsApproximate": true,
  "publishedAtText": "3 days ago",
  "hashtags": ["creative"],
  "channel": {
    "channelName": "Example Creator",
    "handle": "@ExampleCreator",
    "subscriberCountText": "12.3K subscribers",
    "subscriberCountIsApproximate": true
  }
}
```

Rounded counts retain their displayed labels and are marked approximate. Relative dates remain text; no exact timestamp is inferred. Optional values appear only when visible on the public page.

### Content-gap comparison and cost

Review the run output for the topic comparison, including shared topics and candidate gaps by source. The comparison uses terms found in sampled titles, card-description snippets, and hashtags; it does not assess full video content.

Check the Actor's Pricing tab for current Actor and Apify platform charges. Run volume depends on the number of sources and the per-source video limit.

### Authorized YouTube Data API mode (default off)

`youtubeDataApiMode` is **false by default**. When set to `true`, the Actor uses a separate authorized adapter backed by `search.list`, `videos.list`, and `channels.list`. The original public HTML parser is unchanged and remains the path for every existing run.

```json
{"youtubeDataApiMode":true,"queries":["nasa rocket"],"maxItems":10}
```

**Credential — one documented mechanism:** a protected environment secret. Set `APIFY_SECRET_YOUTUBE_DATA_API_KEY` (or `YOUTUBE_DATA_API_KEY`) in your own authorized Apify project; `apify@3.7.2` has no `Actor.getSecret()`. Keys are never accepted as Actor input, never placed in a request URL (they travel only in the `X-Goog-Api-Key` header), and never written to datasets, logs, key-value-store records, or QA artifacts. With no configured secret the run makes zero requests and emits zero rows.

**Bounds and provenance:** at most 2 queries and at most 10 unique video IDs. Candidate videos are emitted in the provider's actual search-result order; duplicate IDs within a query are skipped, sidebar/recommendation containers are never treated as results, and missing results are never padded. Titles, URLs, channel attribution, and timestamps are source-backed. `viewCount` is the exact API-supplied count (not an estimate); absent statistics stay absent. `publishedAt` preserves the source timestamp precision verbatim.

**No derived scores:** API mode never computes a content-gap, demand, popularity, ranking, or market-opportunity score from YouTube API metrics, and it never presents an official YouTube measurement. The `topicComparison` artifact is explicitly non-computed in this mode (`topicCount: 0`). The broader content-gap analysis capability remains **PARTIAL/UNVERIFIED** until an authorized methodology with rights review supports its conclusions. YouTube quota (search requests are accounted separately) and a data-retention review are required before enabling this mode.

### Coverage and responsible use

Only standard public video cards from the first response are included; Shorts shelves and advertisements are excluded. Results can vary by locale and public page. Follow YouTube's terms and applicable laws when using the data.

# Actor input Schema

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

One public HTTPS YouTube channel URL or @handle. The Actor reads its first public Videos-page response; individual video URLs are not supported.

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

Ordered public YouTube channel URLs or @handles. Each channel contributes video rows from its first Videos-page response.

## `channelHandles` (type: `array`):

Public channel handles with or without @.

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

Public YouTube channel or search-result URLs. Channel URLs are read from their Videos tab; search pages contribute their visible video cards.

## `sourceUrls` (type: `array`):

Compatibility alias for public YouTube channel or YouTube search-result URLs.

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

Compatibility alias for one public YouTube channel or search-result URL. Individual video URLs are not supported.

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

Maximum number of unique YouTube video records emitted across all supplied sources. Default: 25.

## `deduplicate` (type: `boolean`):

Skip repeated public video IDs across all channel and search sources.

## `includeMedia` (type: `boolean`):

Include public video thumbnail variants and channel avatar/banner URLs when exposed.

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

Delay between sequential public channel/search page requests.

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

Requests are intentionally ordered; only 1 is accepted.

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

Finite retries for transient public requests.

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

Timeout for each public YouTube HTML page request.

## `requestTimeoutMs` (type: `integer`):

Compatibility alias for requestTimeoutSecs.

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

Maximum public HTML bytes retained.

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

Optional ordinary browser user agent; no stealth or fingerprint spoofing is used.

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

Accept-Language value for public requests.

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

Accepted for input compatibility only. This Actor uses direct public HTTP requests and does not route through or rotate proxies.

## `includeLinks` (type: `boolean`):

Include structured external links associated with the public channel header or About data when present.

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

Optional public YouTube search queries. Search pages are treated as comparison sources, not as owned channels.

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

Compatibility alias for one public YouTube search query.

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

Compatibility alias for one public YouTube search query.

## `includeHashtags` (type: `boolean`):

Include hashtags visible in each video title or card-description excerpt.

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

Maximum standard public video cards read from each source's first response. Shorts shelves and advertisements are excluded.

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

Locked to page 1. The Actor currently reads only the first public response for each source and does not continue YouTube's dynamic feed.

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

Locked to 1 page per source; dynamic YouTube continuation is not implemented.

## `youtubeDataApiMode` (type: `boolean`):

OFF by default. When true, the Actor uses the YouTube Data API with a protected environment secret instead of public HTML pages. Accepts at most 2 queries and emits at most 10 video IDs in provider order. No content-gap, demand, or opportunity score is computed from API metrics. Keys are never accepted as input.

## Actor input object example

```json
{
  "maxItems": 25,
  "deduplicate": true,
  "includeMedia": true,
  "requestDelayMs": 500,
  "maxConcurrency": 1,
  "maxRequestRetries": 1,
  "requestTimeoutSecs": 30,
  "maxResponseBytes": 2000000,
  "locale": "en-US",
  "includeLinks": true,
  "includeHashtags": true,
  "maxVideosPerSource": 10,
  "page": 1,
  "maxPages": 1,
  "youtubeDataApiMode": false
}
```

# Actor output Schema

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

No description

## `contentGapAnalysis` (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-content-gap-analysis-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-content-gap-analysis-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-content-gap-analysis-scraper --silent --output-dataset

```

## MCP server setup

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