# youtube.search

Search YouTube: the videos, Shorts, channels and playlists on the first page of results for a query.

YouTube search, one of the YouTube scrapers.

| | |
| --- | --- |
| Id | `youtube.search` |
| Version | 1 |
| Billed per | record — 1 unit for each record of a charged run |
| Runs | within one request |

Start it with `POST /v1/scrapers/youtube.search/runs`. How runs work is in [Running a scraper](https://docs.enrichednow.com/running-a-scraper.md); what a run costs is in [Usage and units](https://docs.enrichednow.com/usage-and-units.md).

## Inputs

The fields of `input`. A field that is not listed here is refused.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | yes | What to search YouTube for. Limit: at least 1 characters, at most 200 characters. |
| `max_results` | integer | no | The most results to return. Results load about 20 at a time, so a larger number takes longer; fewer come back when YouTube has no more. Limit: 1 to 100. Default: `20`. |
| `type` | "video" \| "channel" \| "playlist" \| "short" \| "movie" | no | Only results of this kind (YouTube's own Type filter). Leave out for the mixed results YouTube shows by default. |

- Results load about 20 at a time (the first page also carries Shorts). `max_results` goes up to 100: a run that asks for more than the first page loads the next results until it has enough or YouTube has no more, so it takes longer.
- If a later batch of results cannot be loaded, the run ends `partial` with the results it has.
- Sponsored results are left out.
- A search nothing matches ends `ok` with zero records, when YouTube shows its own "No results found". With `type`, a page that holds only results of other kinds ends the run `failed` with `layout_not_recognised`; with `type: movie`, it ends `ok` with zero records, since YouTube answers the films filter with videos where it has no film for the words.
- `type: movie` returns the films of YouTube Movies & TV, each with `movie_details` (genre and year) and `movie_credits` as shown.
- Counts are kept as YouTube shows them, in `view_count_text` and the like; the number beside it is filled only when the text can be read as one, and `view_count_exact` is `false` for a rounded count.
- Billed per record: a charged run costs 1 unit for each result it returns.
- YouTube's cookie-consent page (`consent_wall`) and its bot check (`bot_check`) end the run `failed` — see [the reasons of this family](https://docs.enrichednow.com/results-and-statuses.md#youtube).

## Record fields

Every record of a run has these fields. A value that is not known is `null` — never an empty string and never `0`.

| Field | Type | Notes |
| --- | --- | --- |
| `type` | "video" \| "short" \| "channel" \| "playlist" \| "movie" | What the result is: a video, a short (a YouTube Short), a channel, a playlist, or a film YouTube sells, rents or shows with ads. A course, a podcast or a show is returned as a playlist. |
| `position` | integer | Its place on the page, from 1, counting every result returned. |
| `id` | string | The video id, channel id (UC…) or playlist id. |
| `url` | string | Its address on YouTube: youtube.com/watch?v=<id> for a video, /shorts/<id> for a Short, /channel/<id> for a channel, /playlist?list=<id> for a playlist. |
| `title` | string or null | The title as shown; for a channel, its name. |
| `channel_name` | string or null | The channel that published it; for a channel result, the channel itself. |
| `channel_id` | string or null | The id (UC…) of that channel; null where the result names no channel (a Short in a shelf). |
| `channel_url` | string or null | That channel's address, as the page links it: by its handle (youtube.com/@name) where it has one. |
| `channel_handle` | string or null | @name, when the page links the channel by its handle. |
| `channel_verified` | boolean or null | The channel shows a verified or official-artist badge; null where the result names no channel. |
| `published_text` | string or null | When it was published, as shown ("11y ago"). |
| `duration_text` | string or null | The length as shown ("12:44"). |
| `duration_seconds` | integer or null | The length in seconds, read from `duration_text`; null where the result shows no length. |
| `view_count_text` | string or null | The views as shown ("10,140,636 views", "511K views"). |
| `view_count` | integer or null | The views as a number, when the text reads as one. |
| `view_count_exact` | boolean or null | True when YouTube showed the count in full, false when it showed it rounded (511K). |
| `is_live` | boolean or null | A live stream that is on air now. |
| `live_viewers` | integer or null | People watching now, for a live stream. |
| `subscriber_count_text` | string or null | For a channel: its subscribers as shown ("71.1K subscribers"). |
| `subscriber_count` | integer or null | For a channel: the shown figure as a number (YouTube rounds it to three figures). |
| `video_count_text` | string or null | For a playlist or a channel: its number of videos as shown ("80 videos", "16 lessons", "42 episodes"). |
| `video_count` | integer or null | The number in `video_count_text`, when the text reads as one. |
| `description_snippet` | string or null | The lines of description shown under the result. |
| `badges` | array of string | The labels shown on the result ("LIVE", "New", "4K", "CC"). |
| `thumbnails` | array of object | The result's thumbnail (for a channel, its picture), in the sizes the page lists, smallest first. |
| `thumbnails[].url` | string | The image's address. |
| `thumbnails[].width` | integer or null | Its width in pixels, when the page states it. |
| `thumbnails[].height` | integer or null | Its height in pixels, when the page states it. |
| `movie_details` | string or null | For a film: its genre and year as shown ("Action & adventure • 2016"). |
| `movie_credits` | array of string | For a film: the credits as shown ("Actors: …", "Director: …"). |

## Example request

It starts a run with this scraper's example input and waits up to 60 seconds for it. The key is read from `ENRICHEDNOW_API_KEY`.

```bash
curl -X POST "https://api.enrichednow.com/v1/scrapers/youtube.search/runs?wait=60" \
  -H "Authorization: Bearer $ENRICHEDNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":{"query":"how to weld aluminum"}}'
```

## Example response

The run, once it has ended. A run that has not ended within `wait` comes back with `202` and the status `queued` or `running`.

```json
{
  "id": "run_841742f37553189ff9c27ba1",
  "scraper_id": "youtube.search",
  "scraper_version": 1,
  "status": "ok",
  "reason": null,
  "input": {
    "query": "how to weld aluminum"
  },
  "record_count": 1,
  "units": 1,
  "units_per_request": null,
  "units_per_record": 1,
  "units_per_page": null,
  "diagnostics": {
    "requests": 1,
    "bytes": 259214,
    "wall_ms": 885,
    "facts": {}
  },
  "created_at": "2026-11-16T22:37:50.170950Z",
  "started_at": "2026-11-16T22:37:50.178331Z",
  "finished_at": "2026-11-16T22:37:51.066313Z"
}
```

Its records, from `GET /v1/runs/{id}/records`. The record is a real one: this scraper's own parser read it from a page recorded from the site.

```json
{
  "records": [
    {
      "type": "video",
      "position": 1,
      "id": "jtvOkI_pvMI",
      "url": "https://www.youtube.com/watch?v=jtvOkI_pvMI",
      "title": "How to \"Weld\" Aluminum Without a Welder",
      "channel_name": "Make Something",
      "channel_id": "UCtaykeSsGhtn2o2BsPm-rsw",
      "channel_url": "https://www.youtube.com/@MakeSomething",
      "channel_handle": "@MakeSomething",
      "channel_verified": true,
      "published_text": "11y ago",
      "duration_text": "2:17",
      "duration_seconds": 137,
      "view_count_text": "10,140,636 views",
      "view_count": 10140636,
      "view_count_exact": true,
      "is_live": false,
      "live_viewers": null,
      "subscriber_count_text": null,
      "subscriber_count": null,
      "video_count_text": null,
      "video_count": null,
      "description_snippet": "Brazing aluminum with a propane torch and brazing rods. Watch the full build of the lift top coffee table: ...",
      "badges": [],
      "thumbnails": [
        {
          "url": "https://i.ytimg.com/vi/jtvOkI_pvMI/hq720.jpg?sqp=-oaymwEcCOgCEMoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLD34IkJi-oRpvyds-hK_yGt8CJtjg",
          "width": 360,
          "height": 202
        },
        {
          "url": "https://i.ytimg.com/vi/jtvOkI_pvMI/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLAjEh_pzlpRFbjizHwK0qCVZjCFkQ",
          "width": 720,
          "height": 404
        }
      ],
      "movie_details": null,
      "movie_credits": []
    }
  ],
  "next_cursor": null
}
```

A run does not always end `ok`. [Results and statuses](https://docs.enrichednow.com/results-and-statuses.md#reason-codes) lists every status and the reasons every scraper shares; [the reasons of the YouTube scrapers](https://docs.enrichednow.com/results-and-statuses.md#youtube) are in their own section there.
