# YouTube Search → Video IDs (`skilled_glee/youtube-search-videos`) Actor

Search YouTube by keyword and get a flat list of videos: videoId, URL, title, channel, views, duration, upload age. Filters for upload date, duration and sort. Discover step only: hand the IDs to a transcript or comments Actor.

- **URL**: https://apify.com/skilled_glee/youtube-search-videos.md
- **Developed by:** [EchoEmpire Machine Foundry (EchoEmpire LLC)](https://apify.com/skilled_glee) (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

$7.88 / 1,000 video listeds

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 → Video IDs

Search terms in, a flat list of YouTube videos out: video ID, URL, title, channel, views, duration and upload age. One row per video.

### Which YouTube Actor should I use?

This is a **narrow Discover step**. It finds videos for a keyword and stops there. It does **not** download transcripts, comments, likes, full descriptions, Shorts or channel pages. Hand the `videoId`/`url` it returns to the next step:

| Next step | Actor |
|---|---|
| Captions as timestamped JSON | [YouTube Transcript Extractor](https://apify.com/skilled_glee/youtube-transcript-extractor) |
| Comments | [YouTube Comments Extractor](https://apify.com/skilled_glee/youtube-comments-extractor) |
| RAG chunks from subtitles | [Subtitle RAG Chunker](https://apify.com/skilled_glee/subtitle-rag-chunker) |
| All videos of one channel | [YouTube Channel Videos](https://apify.com/skilled_glee/youtube-channel-videos) |

| | |
|---|---|
| Input | `queries[]`, optional `maxResultsPerQuery`, `sortBy`, `uploadDate`, `duration`, `language`, `country` |
| Output per video | `videoId`, `url`, `title`, `channelName`, `channelId`, `channelUrl`, `viewCount`, `durationSeconds`, `publishedTimeText`, `publishedAtEstimate`, `isLive`, `descriptionSnippet`, `thumbnailUrl`, `query`, `rank` |
| Pricing | $0.00788 per video listed ($7.88 / 1,000). Queries with no results are not billed. |
| Access | YouTube's public web search endpoint. No login, no API key, no browser. |
| Call it | REST `skilled_glee~youtube-search-videos` · MCP `https://mcp.apify.com/?tools=skilled_glee/youtube-search-videos` |

Pipeline role (n8n / agents): **Content → Discover**. Search → Transcript → Chunk is one n8n flow. Full catalog: [EchoEmpire Machine Foundry llms.txt](https://foundry.echoempire.org/llms.txt).

### Input

```json
{
  "queries": ["n8n tutorial"],
  "maxResultsPerQuery": 5,
  "sortBy": "relevance",
  "uploadDate": "month",
  "duration": "medium"
}
```

- `queries` (required, 1–50).
- `maxResultsPerQuery` (1–500, default 50). Results come in pages of about 20; the Actor stops at your limit or when YouTube has no more results.
- `sortBy`: `relevance` (default) or `view_count`. YouTube no longer honors an "upload date" sort, so it is not offered; use `uploadDate` to get recent videos.
- `uploadDate`: `any`, `today`, `week`, `month`, `year`.
- `duration`: `any`, `short` (< 4 min), `medium` (4–20 min), `long` (> 20 min).
- `language` (`hl`, default `en`) and `country` (`gl`, default `US`).

### Output

Row from a real run (2026-10-29):

```json
{"query": "n8n tutorial", "rank": 1, "videoId": "xl7Y49yLPDs", "url": "https://www.youtube.com/watch?v=xl7Y49yLPDs", "title": "n8n Tutorial for Beginners in 2026: How to Build AI Agents", "channelName": "Youri van Hofwegen", "channelId": "UCdR7eGozLjafYMTd2BFnJaQ", "channelUrl": "https://www.youtube.com/@Yourivanhofwegen", "viewCount": 44366, "viewCountText": "44,366 views", "publishedTimeText": "2 weeks ago", "publishedAtEstimate": "2026-10-16", "durationSeconds": 1052, "durationText": "17:32", "isLive": false, "descriptionSnippet": "Host n8n with Hostinger ...", "thumbnailUrl": "https://i.ytimg.com/vi/xl7Y49yLPDs/hq720.jpg", "status": "ok"}
```

Field notes:

- YouTube search shows upload time only as relative text ("2 weeks ago"). `publishedTimeText` is that text; `publishedAtEstimate` is computed from it at run time, so it is **approximate** (a date for day/week/month/year units). For exact dates, use a details/transcript step.
- `viewCount` is `null` for live streams (YouTube shows "watching" instead of views).
- `rank` is the position within that query's results in this run.

A query that returns nothing (or that YouTube refuses) produces one row `{"query": "...", "status": "error", "error": "..."}` and is not billed. `SUMMARY` in the default key-value store has per-query counts and whether a spending limit stopped the run.

### Pricing (pay per event)

| Event | When | Price |
|---|---|---|
| `video-listed` | Once per video row with `status: "ok"` saved to the dataset | $0.00788 |

No start fee. Error rows are free. Example: 4 queries × 50 videos = 200 × $0.00788 = $1.58.

### Limits

- Regular videos only (the search runs with YouTube's "Videos" type filter); Shorts shelves, playlists and channels are skipped.
- Results are what YouTube's web search returns for an anonymous visitor from the Apify cloud for your `language`/`country`; they can differ from a signed-in search.
- YouTube can rate-limit requests; affected queries return error rows.

# Actor input Schema

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

1-50 search terms, as you would type them in the YouTube search box.

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

1-500. The Actor pages through results until this number or the end of results. Billing is per video row.

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

relevance (YouTube default) or view_count. For newest videos, use the Upload date filter (YouTube no longer honors an upload-date sort).

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

Only videos uploaded within this window.

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

YouTube's own duration buckets: short < 4 min, medium 4-20 min, long > 20 min.

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

Language code for YouTube's interface text (affects relative dates and result ranking), e.g. en, de, es.

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

Two-letter country code for result ranking, e.g. US, GB, DE.

## Actor input object example

```json
{
  "queries": [
    "n8n tutorial"
  ],
  "maxResultsPerQuery": 50,
  "sortBy": "relevance",
  "uploadDate": "any",
  "duration": "any",
  "language": "en",
  "country": "US"
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "queries": [
        "n8n tutorial"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("skilled_glee/youtube-search-videos").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": ["n8n tutorial"] }

# Run the Actor and wait for it to finish
run = client.actor("skilled_glee/youtube-search-videos").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": [
    "n8n tutorial"
  ]
}' |
apify call skilled_glee/youtube-search-videos --silent --output-dataset

```

## MCP server setup

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

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/pdSrdNWJUAz6kM3dn/builds/hagnEq6DCYlrich22/openapi.json
