# YouTube Audience & Competitor Intelligence (`datahunter_labs/youtube-audience-competitor-intelligence`) Actor

Analyze public YouTube comments through the official YouTube Data API: sentiment, complaints, feature requests, questions, competitor mentions, switching signals, and change monitoring.

- **URL**: https://apify.com/datahunter\_labs/youtube-audience-competitor-intelligence.md
- **Developed by:** [DataHunter Labs](https://apify.com/datahunter_labs) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 analyzed comments

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 Audience & Competitor Intelligence

Turn public YouTube comments into structured audience intelligence using the **official YouTube Data API v3**. No browser automation, private YouTube endpoints, login automation, CAPTCHA solving, or proxy rotation is used.

### What it does

For each public video, the Actor returns comment-level intelligence including sentiment, complaint categories, complaint score, audience intent, feature-request signals, questions, purchase intent, competitor mentions, and switching signals. It also emits a free per-video summary and supports monitoring newly observed comments across scheduled runs.

### Why this Actor exists

Raw YouTube comment scrapers already exist. This Actor focuses on the commercial layer above raw extraction: product feedback, customer pain points, competitive switching, feature demand, and audience questions.

### Source and stability

The Actor uses Google's official YouTube Data API v3 only. `commentThreads.list`, `comments.list`, and `videos.list` are documented public endpoints. A user-supplied API key is required and is marked `isSecret: true` in the Apify input schema.

Typical public-read quota cost is 1 unit per list request. Your Google Cloud project's YouTube quota is separate from Apify billing.

### Inputs

- `youtubeApiKey`: encrypted YouTube Data API v3 key.
- `videoUrls`: YouTube URLs or 11-character video IDs.
- `maxCommentsPerVideo`: result cap.
- `order`: newest (`time`) or relevance.
- `searchTerms`: optional API-side comment text filter.
- `competitorNames`: optional names to detect.
- `includeReplies`: fetch replies; may consume more quota.
- `monitorChanges` / `onlyNewComments`: incremental monitoring.
- `maxConcurrency`: bounded video concurrency (default 2, maximum 5).
- request, timeout, and retry caps prevent runaway runs.

### Output

Dataset records are one of:

- `comment` — useful comment intelligence row.
- `video_summary` — free aggregate summary for that video.
- `diagnostic` — free actionable error/limit row.

Public author display names are **excluded by default**. Enable `includeAuthorName` only when needed.

Comment rows keep video-level `likeCount` and expose the comment's own likes separately as `commentLikeCount`, so the two metrics cannot overwrite each other.

### Example input

```json
{
  "youtubeApiKey": "YOUR_KEY",
  "videoUrls": ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"],
  "maxCommentsPerVideo": 100,
  "competitorNames": ["Spotify", "TikTok"],
  "monitorChanges": true
}
```

### Example intelligence row

```json
{
  "recordType": "comment",
  "videoId": "dQw4w9WgXcQ",
  "commentText": "Too many ads. I'm switching to Spotify.",
  "sentiment": "negative",
  "complaintCategories": ["ads"],
  "switchingSignal": true,
  "competitorsMentioned": ["Spotify"],
  "audienceIntent": "switching"
}
```

### Monitoring behavior

Monitoring state is Actor-scoped and keyed by the video plus order/search/reply/competitor settings that affect the result set. Changing those settings creates a separate baseline instead of producing false change alerts. On the first monitoring run, `isNewSinceLastRun` and `newCommentsSinceLastRun` are `null` because there is no earlier run to compare against. When monitoring is disabled, both change fields are also `null`.

### Error behavior

- `commentsDisabled`: diagnostic row, no retry loop.
- invalid video: diagnostic row.
- 408/429/5xx/network failures: bounded exponential retries.
- `quotaExceeded`, `dailyLimitExceeded`, invalid key, or API-not-enabled: circuit breaker stops additional YouTube requests.
- request budget reached: graceful partial success.

### Pricing

Suggested PPE event: **`comment-returned` = $0.0015 per successfully delivered new comment intelligence row** ($1.50 / 1,000). Summaries, diagnostics, retries, API failures, cached duplicates, and previously seen monitoring rows are not custom-billed.

The event definition in this package does **not** activate monetization by itself. Configure Pay Per Event in Apify Console before publishing.

### Limits

This version targets public video comments. Comments can be disabled by a video owner. The YouTube Data API has its own quota limits. The Actor does not bypass those limits.

### Independence

DataHunter\_Labs is independent and is not affiliated with or endorsed by YouTube or Google.

# Changelog

This Actor's version history is a separate document: https://apify.com/datahunter\_labs/youtube-audience-competitor-intelligence/changelog.md

# Actor input Schema

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

Google Cloud YouTube Data API v3 key. Stored encrypted by Apify. The Actor uses only Google's official public API endpoints.

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

Video URLs, Shorts URLs, youtu.be links, Live URLs, embed URLs, or bare 11-character video IDs.

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

Maximum top-level comments and optional replies returned per video.

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

YouTube commentThreads order.

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

Optional YouTube API comment search terms. Leave blank for all comments.

## `competitorNames` (type: `array`):

Optional brands, products, creators, or apps to detect in comments and switching signals.

## `includeReplies` (type: `boolean`):

Include replies. Extra API requests are used only when YouTube's embedded reply subset is incomplete.

## `maxRepliesPerThread` (type: `integer`):

Hard per-thread reply cap when replies are enabled.

## `includeAuthorName` (type: `boolean`):

Off by default to minimize unnecessary personal identifiers.

## `monitorChanges` (type: `boolean`):

Persist comment IDs per video and relevant filters so later runs identify newly observed comments.

## `onlyNewComments` (type: `boolean`):

After a monitoring baseline exists, emit only newly observed comments plus the free video summary.

## `cacheTtlMinutes` (type: `integer`):

Used only for non-monitoring runs to reduce repeated API calls.

## `forceRefresh` (type: `boolean`):

Ignore a valid cache entry on non-monitoring runs.

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

Maximum videos processed concurrently. Kept low to avoid quota spikes on one API key.

## `maxRequestsPerRun` (type: `integer`):

Hard cap on API requests, including retries and optional reply pagination.

## `timeoutSeconds` (type: `integer`):

Timeout per official YouTube Data API request.

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

Bounded retries for 408, 429 and transient 5xx/network failures.

## `retryBackoffSeconds` (type: `integer`):

Base exponential backoff between transient retries.

## Actor input object example

```json
{
  "videoUrls": [
    "dQw4w9WgXcQ"
  ],
  "maxCommentsPerVideo": 100,
  "order": "time",
  "searchTerms": "",
  "competitorNames": [],
  "includeReplies": false,
  "maxRepliesPerThread": 20,
  "includeAuthorName": false,
  "monitorChanges": true,
  "onlyNewComments": false,
  "cacheTtlMinutes": 60,
  "forceRefresh": false,
  "maxConcurrency": 2,
  "maxRequestsPerRun": 100,
  "timeoutSeconds": 20,
  "maxRetries": 2,
  "retryBackoffSeconds": 1
}
```

# Actor output Schema

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

Comment intelligence, video summary, and diagnostic rows.

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

Run-level request, result, and circuit status stored in OUTPUT.

# 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 = {
    "videoUrls": [
        "dQw4w9WgXcQ"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("datahunter_labs/youtube-audience-competitor-intelligence").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 = { "videoUrls": ["dQw4w9WgXcQ"] }

# Run the Actor and wait for it to finish
run = client.actor("datahunter_labs/youtube-audience-competitor-intelligence").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 '{
  "videoUrls": [
    "dQw4w9WgXcQ"
  ]
}' |
apify call datahunter_labs/youtube-audience-competitor-intelligence --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datahunter_labs/youtube-audience-competitor-intelligence"
        }
    }
}
```

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/SEsfsLwWxkSGnNkYK/builds/X35la5AAbbmv0BEBq/openapi.json
