# YouTube Search Scraper - Views & Strict Date Filter, $0.09/1K (`sweet_stickball/youtube-search-scraper`) Actor

YouTube search scraper and YouTube search API alternative: extract videos for any keyword with title, URL, channel, view count, duration, publish date, live and Shorts flags. Filter by upload date, duration, type and country. Fast InnerTube access, flat JSON, no login or YouTube API key.

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

## Pricing

from $0.05 / 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.
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 Scraper - Views & Strict Date Filter, $0.09/1K

Search YouTube by keyword and get one flat JSON row per video result: exact view count, duration, channel, publish date, description snippet, badges, live and Shorts flags. Filters for upload date, duration, popularity, country and language. No API key or login.

### What it does

- Takes one or more search terms (`searchQueries`) and returns up to `maxItems` videos for each, in YouTube's order.
- Reads YouTube's own search API (the one used by youtube.com), page by page, until `maxItems` or the end of YouTube's results.
- Each row carries the exact view count (`58,483,417 views` becomes `58483417`), the duration in seconds, the channel id, handle, URL and verified flag, the description snippet shown under the result, and the badges (`LIVE`, `New`, `4K`, `CC`, `3 products`...).
- Applies YouTube's search filters: upload date, duration, popularity ranking, videos or Shorts, country, interface language.
- Removes duplicate videos within a query and returns the rank of each video (`position`).
- Fails with an explicit message (blocked, or no results for these filters) instead of returning an empty dataset.

### Input

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `searchQueries` | array of strings | Yes | — | Search terms, one per line (e.g. `lofi hip hop`). A single string is also accepted. Duplicates are removed. |
| `maxItems` | integer | No | 20 | Maximum videos per query (1 to 5,000). |
| `sortBy` | string | No | `relevance` | `relevance` (YouTube's default ranking) or `popularity` (most viewed first). |
| `uploadDate` | string | No | `any` | `any`, `today`, `week`, `month` or `year`. |
| `duration` | string | No | `any` | `any`, `short` (under 3 min), `medium` (3 to 20 min), `long` (over 20 min). |
| `type` | string | No | `video` | `video` (regular videos and live streams) or `shorts`. |
| `country` | string | No | `US` | Two-letter country code whose results are returned (`US`, `GB`, `DE`, `IN`...). |
| `language` | string | No | English | YouTube interface language (`fr`, `es`, `de`, `pt-BR`...). Results are ranked for speakers of that language and texts come back in it. Exact view counts are still parsed; see Limitations for what changes. |

Example:

```json
{
    "searchQueries": ["lofi hip hop", "python tutorial"],
    "maxItems": 50,
    "sortBy": "popularity",
    "uploadDate": "month",
    "duration": "long"
}
```

### Output

One dataset item per video (real item from a run on 2026-11-02):

```json
{
    "videoId": "CLeZyIID9Bo",
    "url": "https://www.youtube.com/watch?v=CLeZyIID9Bo",
    "title": "Chill Lofi Mix [chill lo-fi hip hop beats]",
    "descriptionSnippet": "YouTube Playlists: http://listen.settle.fm/youtube Listen on Spotify, Apple Music & more: https://listen.settle.fm/playlists Tracklist ...",
    "channelName": "Settle",
    "channelId": "UCkKT4qf-TcPFOmpqhTawrGA",
    "channelHandle": "@settlefm",
    "channelUrl": "https://www.youtube.com/@settlefm",
    "channelVerified": false,
    "channelIsArtist": false,
    "channelAvatarUrl": "https://yt3.ggpht.com/89HydDCrVDqoTZbqoXQHr7HkQjDnvDrkkUyBFh_wP3dWm0RYHj6QtlDOvV9dcZgYEJFareVIBg=s68-c-k-c0x00ffffff-no-rj",
    "viewCount": 35171113,
    "viewCountText": "35,171,113 views",
    "liveViewerCount": null,
    "publishedText": "4 years ago",
    "publishedAt": "2022-11-03T20:21:55+00:00",
    "durationSeconds": 6292,
    "durationText": "1:44:52",
    "thumbnailUrl": "https://i.ytimg.com/vi/CLeZyIID9Bo/hq720.jpg?sqp=-oaymwE2CNAFEJQDSFXyq4qpAygIARUAAIhCGAFwAcABBvABAfgB_gmAAtAFigIMCAAQARhDIGQoZTAP&rs=AOn4CLCljfsoUy4QvdaH9IydXKSjwkcbgg",
    "isLive": false,
    "isUpcoming": false,
    "isShort": false,
    "badges": ["4K"],
    "position": 8,
    "query": "lofi hip hop",
    "scrapedAt": "2026-11-02T20:21:55+00:00"
}
```

Field notes:

- `viewCount` is `null` for streams that are live now; their current audience is in `liveViewerCount`.
- `publishedAt` is computed from the relative text YouTube shows (`4 years ago`) and the scrape time, counting a month as 30 days and a year as 365 days: it is approximate. `publishedText` keeps the original text.
- `channelName` is the byline shown by YouTube; for a video published by several channels it reads `A and B`, and `channelId` is the first one.
- `descriptionSnippet` is the excerpt YouTube shows under the result, not the full description.

### Pricing

Pay-per-event, no start fee: **$0.09 per 1,000 videos** (event `VIDEO`) on the Apify Free plan, lower on paid plans. You only pay for results pushed to the dataset.

| Apify plan | Price per 1,000 videos |
|---|---|
| Free | $0.09 |
| Starter | $0.08 |
| Scale | $0.07 |
| Business | $0.05 |

Set a maximum cost per run in the run options: the Actor stops cleanly when it is reached.

### Limitations

- YouTube no longer offers a sort by upload date (only Relevance and Popularity). To get recent videos, use `uploadDate`.
- YouTube's upload date filter lets some older videos through; the Actor drops results whose displayed age is older than the chosen period. Streams that are live now have no date and are kept.
- With `type: shorts`, YouTube's search shows only the title, a rounded view count and the thumbnail: channel, date, duration and description are `null`.
- YouTube search returns a limited number of results per query: on 2026-11-02, 325 videos for `lofi hip hop` and 400 for `how to tie a tie` before YouTube stopped returning new ones. A higher `maxItems` returns what YouTube provides; split broad topics into several queries to get more.
- Exact publish dates, like counts, comment counts and full descriptions are not part of search results.
- Texts are read in English by default; `country` changes which results are returned, not the language of the dates.
- With a `language` other than English (for example `fr`): exact `viewCount` is still parsed from the localized text (`1 330 vues` gives 1330), but `publishedAt` is `null` (`publishedText` keeps the localized text such as `il y a 13 jours`), the Actor's extra check on `uploadDate` is skipped (YouTube's own filter still applies), and the rounded view counts of Shorts cards and texts such as `Aucune vue` give `viewCount: null`.

### Feedback

Found a bug or need a field? Open an issue on the Issues tab; if the Actor helps you, a review on the Reviews tab helps others find it.

### Related Actors

- [YouTube Channel Scraper - Videos, Shorts & Stats, $0.91/1K](https://apify.com/sweet_stickball/youtube-channel-scraper) — YouTube channel scraper and YouTube Data API alternative: list a channel's videos, Shorts or live streams with exact view counts, duration and publish date, plus subscribers, video count, total views and country.
- [YouTube Comments Scraper - Replies, Likes, Dates, $0.36/1K](https://apify.com/sweet_stickball/youtube-comments-scraper) — YouTube comments scraper and API alternative: extract comments and replies from YouTube videos and Shorts with text, like and reply counts, pinned and hearted flags and date.
- [YouTube Transcript Scraper - Bulk, Any Language, $1.10/1K](https://apify.com/sweet_stickball/youtube-transcripts) — Scrape YouTube video transcripts (captions and auto-generated subtitles) with timestamps, video metadata and optional comments.

# Actor input Schema

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

Search terms, one per line, typed as in the YouTube search box (e.g. 'lofi hip hop', 'python tutorial'). Each query is searched separately; duplicates are removed. A single string is also accepted.

## `maxItems` (type: `integer`):

Maximum number of videos returned for EACH query (one dataset row and one VIDEO event per video). Pages of about 20 results are read until this number or the end of YouTube's results is reached.

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

Order of the results, as offered by YouTube's 'Prioritize' filter: 'relevance' (YouTube's default ranking) or 'popularity' (most viewed first). YouTube no longer offers a sort by upload date: use 'Upload date' to get recent videos.

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

Only videos uploaded within this period. YouTube's filter lets a few older videos through: the Actor drops results whose displayed age is older than the period. Videos live right now have no date and are kept.

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

Video length filter of YouTube: 'short' (under 3 minutes), 'medium' (3 to 20 minutes), 'long' (over 20 minutes).

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

'video' (regular videos and live streams, full details) or 'shorts' (Shorts results: title, rounded view count and thumbnail only; YouTube shows no channel, date or duration for them in search).

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

Two-letter country code (ISO 3166-1 alpha-2) whose YouTube results are returned, e.g. US, GB, DE, IN. Texts stay in English unless 'language' is set.

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

Optional YouTube interface language (hl), e.g. 'fr', 'es', 'de', 'pt-BR'. YouTube then ranks results for speakers of that language and returns titles, view and date texts in it. Exact view counts are still parsed; publishedAt is null (publishedText keeps the localized text, e.g. 'il y a 3 jours'), the extra upload-date check is skipped and rounded Shorts counts are left null. Empty = English.

## Actor input object example

```json
{
  "searchQueries": [
    "lofi hip hop",
    "python tutorial"
  ],
  "maxItems": 10,
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "type": "video",
  "country": "US",
  "language": "fr"
}
```

# Actor output Schema

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

One row per video search result, shown with the 'videos' view.

# 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": [
        "lofi hip hop"
    ],
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("sweet_stickball/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": ["lofi hip hop"],
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("sweet_stickball/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": [
    "lofi hip hop"
  ],
  "maxItems": 10
}' |
apify call sweet_stickball/youtube-search-scraper --silent --output-dataset

```

## MCP server setup

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