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

Scrape YouTube search results for any keyword: exact view counts, channel, upload date, duration and description snippet. Filter by upload date and length, sort by views. No API key.

- **URL**: https://apify.com/solarg/youtube-search.md
- **Developed by:** [Solar G](https://apify.com/solarg) (community)
- **Categories:** Videos, SEO tools
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 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

Scrapes YouTube search results for one or more keywords. Each result has its exact view count, rank, channel, upload time, duration, badges and description snippet. No YouTube API key or quota is needed.

### Input

| Field | Description |
|---|---|
| `queries` | Keywords to search. |
| `maxResultsPerQuery` | Default 50, maximum 1,000. YouTube typically returns up to a few hundred results per search. |
| `sortBy` | `relevance` (default) or `views`. |
| `uploadDate` | `any`, `hour`, `today`, `week`, `month` or `year`. |
| `duration` | `any`, `short` (under 4 min), `medium` (4-20 min) or `long` (over 20 min). |
| `country` / `language` | Localises results, for example `GB` / `en`. Default `US` / `en`. |

```json
{
  "queries": ["home espresso machine review"],
  "maxResultsPerQuery": 100,
  "uploadDate": "month",
  "sortBy": "views"
}
```

YouTube no longer offers sorting by upload date. To get the newest videos, use `uploadDate` (for example `today` or `week`).

### Output

Results use the same keys as the other YouTube Actors in this series; keys that search results do not show (such as `likes`) are `null`. Example from a real run:

```json
{
  "query": "home espresso machine review",
  "position": 1,
  "videoId": "PmsWH7xlTCw",
  "url": "https://www.youtube.com/watch?v=PmsWH7xlTCw",
  "title": "Best of 2026: Entry Level Espresso Machines",
  "channel": "Whole Latte Love",
  "channelId": "UCJwRmBtnYh_7Xs9oXUrLhZg",
  "channelUrl": "https://www.youtube.com/@Wholelattelovepage",
  "channelHandle": "@Wholelattelovepage",
  "channelSubscribers": null,
  "channelVerified": true,
  "collaborators": [],
  "views": 55602,
  "concurrentViewers": null,
  "likes": null,
  "commentCount": null,
  "commentCountIsExact": null,
  "duration": "16:19",
  "durationSec": 979,
  "publishDate": null,
  "publishedAt": null,
  "isShort": false,
  "isLive": false,
  "isAgeRestricted": null,
  "isMembersOnly": null,
  "commentsTurnedOff": null,
  "tags": null,
  "category": null,
  "thumbnail": "https://i.ytimg.com/vi/PmsWH7xlTCw/hqdefault.jpg",
  "description": null,
  "hashtags": [],
  "viewsText": "55,602 views",
  "publishedTimeText": "9 days ago",
  "publishedAtApprox": "2026-10-15T00:40:35.974Z",
  "descriptionSnippet": "Looking for the best entry-level espresso machine in 2026? We tested six of the top machines for new home baristas, comparing ...",
  "badges": ["4K"],
  "isPaidContent": false,
  "estimatedTotalResults": 6418831
}
```

Field notes:

- `views` is exact in every language.
- Live streams have `isLive: true` and `concurrentViewers` instead of `views`.
- `publishedAtApprox` is estimated from YouTube's relative time ("9 days ago") and is only filled for English (`language: "en"`). `publishedTimeText` is always the text YouTube shows.
- Search results do not include likes, comment counts, exact dates, tags or category, so these are `null` (unknown). Use the YouTube Scraper for those.
- `isPaidContent` marks films and other paid videos sold through YouTube Movies.

Errors: a search with no results gives one item with `query`, `input` and `error: "No videos found for this search"`. Error items are not charged.

### API usage

```bash
curl -X POST "https://api.apify.com/v2/acts/solarg~youtube-search/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"queries": ["home espresso machine review"], "maxResultsPerQuery": 50}'
```

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("solarg/youtube-search").call(run_input={"queries": ["home espresso machine review"], "maxResultsPerQuery": 50})
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

### Pricing

$0.50 per 1,000 results. Error items are free. Apify paid plans get lower prices: 10% off on Bronze, 20% on Silver and 30% on Gold and above. Platform usage is included in the price.

Report problems in the Issues tab.

# Actor input Schema

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

Keywords to search on YouTube.

## `maxResultsPerQuery` (type: `integer`):

YouTube usually returns up to a few hundred results per search.

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

Order of results: YouTube relevance or highest view count first.

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

Only videos uploaded within this period.

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

Filter results by video length: under 4 minutes, 4 to 20 minutes, or over 20 minutes.

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

Two-letter country code for localised results, e.g. US, GB, DE.

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

Interface language code, e.g. en, de, es.

## Actor input object example

```json
{
  "queries": [
    "home espresso machine review"
  ],
  "maxResultsPerQuery": 20,
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "country": "US",
  "language": "en"
}
```

# Actor output Schema

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

Search results in table form (the Results view of the dataset).

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

Every item in the default dataset, including error items.

# 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 = {
    "queries": [
        "home espresso machine review"
    ],
    "maxResultsPerQuery": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("solarg/youtube-search").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 = {
    "queries": ["home espresso machine review"],
    "maxResultsPerQuery": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("solarg/youtube-search").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 '{
  "queries": [
    "home espresso machine review"
  ],
  "maxResultsPerQuery": 20
}' |
apify call solarg/youtube-search --silent --output-dataset

```

## MCP server setup

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

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/cIJZttxNxlaTc9WRa/builds/uwvMt6N1cHrvkWimn/openapi.json
