# Youtube Search Api (`grow_media/youtube-search-api`) Actor

Search YouTube videos, channels, and playlists using the YouTube Data API. Features comprehensive filtering options, automatic authentication, and detailed results including thumbnails and metadata. Perfect for content research, marketing analysis, and finding targeted videos.

- **URL**: https://apify.com/grow_media/youtube-search-api.md
- **Developed by:** [Grow Media](https://apify.com/grow_media) (community)
- **Categories:** Social media, Automation
- **Stats:** 1,846 total users, 490 monthly users, 100.0% runs succeeded, 49 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.40 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Search API Actor

This [Apify](https://apify.com) actor provides a simple interface to search YouTube videos using the YouTube Data API.

### Features

- Search YouTube videos with comprehensive metadata
- Get up to 1000 video results in a single run
- Automatic pagination handling behind the scenes
- Full video statistics (views, likes, comments)
- Channel information and statistics
- HTML entities properly decoded for better readability

### Input Parameters

The actor accepts the following input parameters:

| Parameter | Type | Description |
|-----------|------|-------------|
| q | String | **Required** - The search query |
| maxResults | Integer | The maximum number of items to return (1-1000, default: 100) |
| useFilters | Boolean | Enable to use advanced filtering options |
| channelType | String | The type of channel to search for (any, show) |
| eventType | String | The event type to search for (completed, live, upcoming) |
| order | String | The order to sort the results by (date, rating, relevance, title, videoCount, viewCount) |
| publishedAfter | String | Only show content published after this date (RFC 3339 format) |
| publishedBefore | String | Only show content published before this date (RFC 3339 format) |
| regionCode | String | The region code for search results (ISO 3166-1 alpha-2 country code, e.g. US) |
| relevanceLanguage | String | The language to search in (ISO 639-1 two-letter language code, e.g. en) |
| safeSearch | String | Whether to include restricted content (moderate, none, strict) |
| videoDefinition | String | Whether to search for HD or standard videos (any, high, standard) |
| videoDuration | String | The duration of videos to search for (any, long, medium, short) |
| videoLicense | String | The license of videos to search for (any, creativeCommon, youtube) |

### Output

The actor outputs a structured dataset with comprehensive information about each video:

```json
{
  "title": "Video Title",
  "type": "video",
  "channelName": "Channel Name",
  "date": "2023-01-01T00:00:00Z",
  "text": "Video description...",
  "thumbnailUrl": "https://i.ytimg.com/vi/VIDEO_ID/hqdefault.jpg",
  "order": 0,
  "input": "search query",
  "hashtags": ["hashtag1", "hashtag2"],
  "channelId": "CHANNEL_ID",
  "channelUrl": "https://www.youtube.com/channel/CHANNEL_ID",
  "channelUsername": "username",
  "numberOfSubscribers": 1000000,
  "channelViewCount": 50000000,
  "channelVideoCount": 500,
  "hiddenSubscriberCount": false,
  "channelCreatedAt": "2020-01-01T00:00:00Z",
  "id": "VIDEO_ID",
  "url": "https://www.youtube.com/watch?v=VIDEO_ID",
  "viewCount": 10000,
  "likes": 1000,
  "commentsCount": 100,
  "commentsTurnedOff": false,
  "duration": 180,
  "keywords": ["keyword1", "keyword2"],
  "isMembersOnly": false
}
```

### Authentication

This actor uses an external token server to authenticate requests to the YouTube API. No additional authentication is required.

### Usage

1. Create a new task for the YouTube Search API actor on the Apify platform
2. Configure your search parameters
3. Run the task
4. Access the results in the task's dataset

### Advantages Over YouTube API Direct Use

- Automatically handles pagination to get up to 1000 results
- Combines multiple API endpoints (search, videos, channels) for comprehensive data
- Properly decodes HTML entities in titles and descriptions
- Extracts hashtags from video descriptions
- Provides clean, consistent data format
- No API key or quota management required

### Limitations

- Focuses exclusively on video search results

# Actor input Schema

## `q` (type: `string`):

Enter keywords to search for on YouTube

## `maxResults` (type: `integer`):

The maximum number of items to return (up to 1000)

## `useFilters` (type: `boolean`):

Enable to use advanced filtering options

## `channelType` (type: `string`):

The type of channel to search for

## `eventType` (type: `string`):

The event type to search for

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

How to sort the search results

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

Only show content published after this date (RFC 3339 format, e.g. 2022-01-01T00:00:00Z)

## `publishedBefore` (type: `string`):

Only show content published before this date (RFC 3339 format, e.g. 2022-12-31T23:59:59Z)

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

The region code for search results (ISO 3166-1 alpha-2 country code, e.g. US)

## `relevanceLanguage` (type: `string`):

The language to search in (ISO 639-1 two-letter language code, e.g. en)

## `safeSearch` (type: `string`):

Whether to include restricted content

## `videoDefinition` (type: `string`):

Whether to search for HD or standard videos

## `videoDuration` (type: `string`):

The duration of videos to search for

## `videoLicense` (type: `string`):

The license of videos to search for

## Actor input object example

```json
{
  "q": "surfing",
  "maxResults": 100,
  "useFilters": false,
  "channelType": "any",
  "order": "relevance",
  "safeSearch": "moderate",
  "videoDefinition": "any",
  "videoDuration": "any",
  "videoLicense": "any"
}
```

# 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("grow_media/youtube-search-api").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("grow_media/youtube-search-api").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 grow_media/youtube-search-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,grow_media/youtube-search-api"
        }
    }
}
```

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/hQ5oHCHkDdXY25L0h/builds/aeVE1Zs8qfKK5vTZv/openapi.json
