# YouTube Search Scraper (`superslowsloth/youtube-search-scraper`) Actor

Scrape YouTube search results without an API key or quota. Returns video ID, title, channel name and ID, view count, duration, publish time and thumbnail for every result, paginated as deep as you need. Counts and dates come back exactly as YouTube renders them, plus a parsed number.

- **URL**: https://apify.com/superslowsloth/youtube-search-scraper.md
- **Developed by:** [Superslow Sloth](https://apify.com/superslowsloth) (community)
- **Categories:** Videos, Social media, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 1,000 videos

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## YouTube Search Scraper

Runs a list of search terms against YouTube and returns the result rows: video
ID, title, channel, duration, view count, thumbnail and whether the video is a
live stream. It talks to the same internal endpoint the YouTube website itself
calls, so it needs no API key and is not subject to the Data API's search quota.

### Input

| Field | Type | Notes |
|---|---|---|
| `searchQueries` | array | Required. One or more search terms. Each is scraped independently. |
| `maxResults` | integer | Videos per query, default 50. Pagination follows YouTube's continuation tokens automatically. |
| `language` | string | `hl` code, default `en`. Changes the language of the display strings YouTube returns. |
| `country` | string | `gl` code, default `US`. Search rankings are region-specific, so this changes the results. |
| `proxyConfiguration` | object | Strongly recommended - see Proxies below. |

### Output

One dataset item per video:

```json
{
  "query": "python tutorial",
  "position": 2,
  "video_id": "fWjsdhR3z3c",
  "url": "https://www.youtube.com/watch?v=fWjsdhR3z3c",
  "title": "Learn Python in Less than 10 Minutes for Beginners (Fast & Easy)",
  "channel_name": "Indently",
  "channel_id": "UCuudpdbKmQWq2PPzYgVCWlA",
  "channel_url": "https://www.youtube.com/@Indently",
  "published_time_text": "5 years ago",
  "published_at_estimate": "2021-08-25",
  "view_count_text": "1,594,228 views",
  "view_count": 1594228,
  "concurrent_viewers": null,
  "duration_text": "10:30",
  "duration_seconds": 630,
  "thumbnail_url": "https://i.ytimg.com/vi/fWjsdhR3z3c/hq720.jpg",
  "is_live": false
}
```

`position` is the video's 1-based rank in YouTube's own ordering for that query,
after duplicates have been removed.

### What the source will and will not give you

YouTube's search response carries **display strings, not numbers**. This actor
emits the string exactly as YouTube printed it, and a parsed number beside it
only where the string could be read without inventing precision.

- **`view_count` is parsed only from an exact count** such as
  `"1,594,228 views"`. When YouTube shows a rounded figure such as `"1.5M
  views"`, `view_count` is `null` and `view_count_text` carries the rounding.
  Reporting `1500000` would be a number the source never stated.
- **`published_at_estimate` is an approximation, and should be treated as one.**
  The response contains no timestamp at all - only text such as `"3 years
  ago"`, which names a bucket roughly a year wide. The estimate is computed by
  subtracting the average length of that unit from the run date. Use
  `published_time_text` when you need what YouTube actually said. For an exact
  publication date you need the watch page or the Data API, not search.
- **Live streams have no duration and no publish date.** `duration_text`,
  `duration_seconds`, `published_time_text` and `published_at_estimate` are all
  `null`, `is_live` is `true`, and the viewer figure lands in
  `concurrent_viewers` rather than `view_count`, because `"12,185 watching"` is
  not a view count.
- **A missing field is `null`, never `0` or `""`.** A zero here would read as a
  measurement, and it would be a false one.
- Search results are a ranked page, not a database. YouTube decides how many
  results exist for a term; asking for 500 when it offers 200 returns 200.

### Proxies

YouTube answers datacenter addresses with "Sign in to confirm you're not a bot".
The actor treats that refusal, along with HTTP 403, 429 and 5xx, as transient:
it rotates to a new proxy exit address and retries. Genuinely broken responses
are permanent and are skipped without burning retries. **Run this with the Apify
residential proxy.** Without a proxy configuration, expect blocks.

### Billing

One `video-scraped` event per row, charged after the row is written to the
dataset, plus a small `actor-start` fee. Duplicates that YouTube repeats across
continuation pages are removed before anything is charged, and a query that
legitimately returns nothing is logged but never charged.

# Actor input Schema

## `searchQueries` (type: `array`):

One or more search terms, exactly as you would type them into YouTube's search box. Each query is scraped independently and every result row records the query it came from.

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

How many videos to return for each query. YouTube serves 12 to 20 per page, so larger values simply follow more continuation pages. Duplicates are removed before this limit is counted.

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

Two-letter language code sent to YouTube as hl, such as en or ja. It changes the language of the display strings YouTube returns, for example "3 years ago".

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

Two-letter country code sent to YouTube as gl, such as US or JP. Search rankings are region-specific, so this changes which videos come back and in what order.

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

Strongly recommended. YouTube answers datacenter addresses with a bot check, and the actor rotates to a new address on every retry.

## Actor input object example

```json
{
  "searchQueries": [
    "python tutorial"
  ],
  "maxResults": 50,
  "language": "en",
  "country": "US",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `videos` (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 = {
    "searchQueries": [
        "python tutorial"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("superslowsloth/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 = {
    "searchQueries": ["python tutorial"],
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("superslowsloth/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 '{
  "searchQueries": [
    "python tutorial"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call superslowsloth/youtube-search-scraper --silent --output-dataset

```

## MCP server setup

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