# Youtube Search Scraper (`akash9078/youtube-search-scraper`) Actor

Search YouTube with one or more queries via the official YouTube Data API and export structured results with optional video-level statistics and durations.

- **URL**: https://apify.com/akash9078/youtube-search-scraper.md
- **Developed by:** [Akash Kumar Naik](https://apify.com/akash9078) (community)
- **Categories:** Developer tools, Videos, Automation
- **Features:** Limited permissions
- **Stats:** 19 total users, 5 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 search 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 Search Scraper** is an Apify Actor that searches YouTube with one or more queries via the official **YouTube Data API v3** and exports structured results — videos, channels, or playlists — with optional video-level statistics and durations.

### What Is YouTube Search Scraper?

This Actor lets you search YouTube programmatically and get structured results including video details, channel information, and statistics. Perfect for content researchers, marketers, and developers building YouTube data pipelines. Results land in the default dataset where they can be exported as JSON, CSV, or Excel.

### Key Features

- **Official YouTube Data API v3** for reliable, stable results
- **Videos, channels, and playlists** — search any resource type
- **Optional video details** — duration, view count, likes, comments via `videos.list`
- **Rich filters** — sort order, video duration, publish date ranges, region, language, and SafeSearch
- **Pagination support** for large result sets (up to 500 results per query)
- **Automatic retries** with exponential backoff
- **Respects user spending limits** automatically
- **Pay-per-event pricing** — $0.01 per search result

### Use Cases

- Content research and trend analysis
- Competitor channel monitoring
- Video metadata collection for ML/AI pipelines
- Building searchable video databases
- YouTube analytics and reporting

### Input Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `searchQuery` | string | Yes | — | YouTube search query (up to 200 characters) |
| `maxResults` | integer | No | `10` | Maximum results to fetch (1–500) |
| `type` | string | No | `video` | Resource type: `video`, `channel`, or `playlist` |
| `order` | string | No | `relevance` | Sort order: `relevance`, `date`, `rating`, `title`, `videoCount`, `viewCount` |
| `videoDuration` | string | No | `any` | `any`, `short` (<4 min), `medium` (4–20 min), `long` (>20 min) — video type only |
| `publishedAfter` | string | No | — | Date or relative time (e.g. "7 days", "2 weeks"); absolute dates use `YYYY-MM-DD` |
| `publishedBefore` | string | No | — | Date or relative time (e.g. "7 days", "2 weeks"); absolute dates use `YYYY-MM-DD` |
| `regionCode` | string | No | — | ISO 3166-1 alpha-2 country code (e.g. `US`, `IN`) |
| `relevanceLanguage` | string | No | — | BCP-47 language tag (e.g. `en`, `hi`) |
| `safeSearch` | string | No | `moderate` | `moderate`, `none`, or `strict` |
| `includeVideoDetails` | boolean | No | `true` | Also fetch duration and statistics (video type only) |

Example input:

```json
{
    "searchQuery": "apify tutorial",
    "maxResults": 50,
    "type": "video",
    "order": "relevance",
    "includeVideoDetails": true
}
```

### Sample Output

Each dataset item contains:

```json
{
    "searchQuery": "apify tutorial",
    "position": 1,
    "resultKind": "video",
    "resultId": "3rrpfW0bEdc",
    "resultUrl": "https://www.youtube.com/watch?v=3rrpfW0bEdc",
    "videoId": "3rrpfW0bEdc",
    "channelId": "UCqD-h6ucBDUntfoapPyhp0Q",
    "title": "Apify Tutorial For Beginners | How To Use Apify",
    "description": "Apify review: https://speakaboutdigital.com/apify-review/",
    "publishedAt": "2023-07-31T08:11:38Z",
    "channelTitle": "Speak About Digital",
    "thumbnailUrl": "https://i.ytimg.com/vi/3rrpfW0bEdc/hqdefault.jpg",
    "duration": "PT10M41S",
    "durationSeconds": 641,
    "viewCount": 30007,
    "likeCount": 338,
    "commentCount": 13,
    "embeddable": true,
    "license": "youtube",
    "privacyStatus": "public"
}
```

### How to Use

1. Open the [Actor page on Apify Store](https://apify.com/akash9078/youtube-search-scraper) and click **Start Actor**.
2. Enter your search query and pick the result type (video, channel, or playlist).
3. Apply filters — sort order, duration, publish dates, region, language, SafeSearch — as needed.
4. Run the Actor and download results as JSON, CSV, or Excel from the dataset.

### How to Use via API

cURL:

```bash
curl -X POST "https://api.apify.com/v2/acts/akash9078/youtube-search-scraper/runs" \
-H "Authorization: Bearer YOUR_APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"searchQuery": "apify tutorial", "maxResults": 50}'
```

Python:

```python
import requests

response = requests.post(
    "https://api.apify.com/v2/acts/akash9078/youtube-search-scraper/runs",
    headers={"Authorization": "Bearer YOUR_APIFY_TOKEN"},
    json={"searchQuery": "apify tutorial", "maxResults": 50},
)
print(response.json())
```

Node.js with [Apify Client](https://docs.apify.com/api/client/js):

```javascript
const { ApifyClient } = require('apify-client');

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

const run = await client.actor('akash9078/youtube-search-scraper').call({
    searchQuery: 'apify tutorial',
    maxResults: 50,
    type: 'video',
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

### Pricing

| Event | Price |
|-------|-------|
| Search Result (`search-result`) | $0.01 per result |

You are charged for each YouTube search result returned (video, channel, or playlist). The Actor respects user-configured spending limits automatically.

### Limitations

- The YouTube Data API has quota limits — keep `maxResults` reasonable
- Some videos may not have like/comment counts available
- Private videos are not accessible
- Search queries are capped at 200 characters

### FAQ

#### Do I need my own YouTube API key?

No. The Actor runs on the official YouTube Data API v3 with the key managed on the Apify platform — just provide a search query.

#### How many results can I get per query?

Between 1 and 500, controlled by `maxResults` (default 10).

#### Can I filter by publish date?

Yes — `publishedAfter` and `publishedBefore` accept absolute dates (`YYYY-MM-DD`) or relative times like "7 days" or "2 weeks".

#### Can I search for channels and playlists?

Yes. Set `type` to `video`, `channel`, or `playlist`. Video-only filters such as duration and `includeVideoDetails` apply when type is `video`.

#### How is billing calculated?

$0.01 per returned search result under the pay-per-event model.

### Related Actors

If you need more YouTube data from Apify, check out my other [Apify Actors](https://apify.com/akash9078):

- [YouTube Transcript Scraper](https://apify.com/akash9078/youtube-transcript-scraper) — extract transcripts from any YouTube video
- [YouTube Transcript Extractor](https://apify.com/akash9078/youtube-transcript-extractor) — transcripts with timestamps in 100+ languages
- [YouTube Full Channel Transcripts Extractor](https://apify.com/akash9078/youtube-full-channel-transcripts-extractor) — transcripts for entire channels
- [YouTube Playlist Scraper with Transcript](https://apify.com/akash9078/youtube-playlist-scraper-with-transcript) — playlist metadata plus transcripts
- [YouTube Channel Video Scraper](https://apify.com/akash9078/youtube-channel-video-scraper) — video metadata for entire channels
- [YouTube Playlist Scraper](https://apify.com/akash9078/youtube-playlist-scraper) — full metadata for every video in a playlist
- [YouTube Trending Scraper](https://apify.com/akash9078/youtube-trending-scraper) — trending videos by region and category

***

Built and maintained by [akash9078](https://apify.com/akash9078) on the [Apify platform](https://docs.apify.com). For issues or questions, visit the [Apify Community](https://apify.com/community) or report bugs via Apify Console.

# Actor input Schema

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

YouTube search query (up to 200 characters).

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

YouTube resource type to search.

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

Maximum number of results to fetch (1-500).

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

Result order used by the YouTube API.

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

Applies only when type is video.

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

Date or relative time (e.g. "7 days", "2 weeks"). Absolute dates use YYYY-MM-DD or YYYY-MM-DDTHH:mm:ssZ.

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

Date or relative time (e.g. "7 days", "2 weeks"). Absolute dates use YYYY-MM-DD or YYYY-MM-DDTHH:mm:ssZ.

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

ISO 3166-1 alpha-2 country code.

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

BCP-47 language tag.

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

SafeSearch level for search results.

## `includeVideoDetails` (type: `boolean`):

When enabled (and type=video), the Actor also fetches duration and statistics via videos.list.

## Actor input object example

```json
{
  "searchQuery": "apify tutorial",
  "type": "video",
  "maxResults": 10,
  "order": "relevance",
  "videoDuration": "any",
  "publishedAfter": "",
  "publishedBefore": "",
  "regionCode": "",
  "relevanceLanguage": "",
  "safeSearch": "moderate",
  "includeVideoDetails": true
}
```

# Actor output Schema

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

Dataset containing all search results across all input queries

# 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 = {
    "searchQuery": "apify tutorial",
    "type": "video",
    "maxResults": 10,
    "order": "relevance",
    "videoDuration": "any",
    "publishedAfter": "",
    "publishedBefore": "",
    "regionCode": "",
    "relevanceLanguage": "",
    "safeSearch": "moderate",
    "includeVideoDetails": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("akash9078/youtube-search-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 = {
    "searchQuery": "apify tutorial",
    "type": "video",
    "maxResults": 10,
    "order": "relevance",
    "videoDuration": "any",
    "publishedAfter": "",
    "publishedBefore": "",
    "regionCode": "",
    "relevanceLanguage": "",
    "safeSearch": "moderate",
    "includeVideoDetails": True,
}

# Run the Actor and wait for it to finish
run = client.actor("akash9078/youtube-search-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 '{
  "searchQuery": "apify tutorial",
  "type": "video",
  "maxResults": 10,
  "order": "relevance",
  "videoDuration": "any",
  "publishedAfter": "",
  "publishedBefore": "",
  "regionCode": "",
  "relevanceLanguage": "",
  "safeSearch": "moderate",
  "includeVideoDetails": true
}' |
apify call akash9078/youtube-search-scraper --silent --output-dataset

```

## MCP server setup

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