# YouTube: Search videos

`youtube/videos/search` · version 1.0.1 · pilot · 1 credits a call

One page of a YouTube search, about 20 videos in the order youtube.com shows them, each with its channel, views, duration, date, badges, chapters and thumbnails.

Categories: Social media, SEO

## When to use

You need the videos YouTube finds for some words, as its search shows them to a visitor: their title, channel, views, duration, when they were published, whether they are live, upcoming or shorts, their badges (4K, CC, New), the chapters the result shows (the one matching the words marked), YouTube's AI summary of the video when the result shows one, and their thumbnails. Filter as the search's panel does: by type (videos or shorts), upload date (today to this year), duration and features (live, 4K, HD, subtitles, Creative Commons, 360°, VR180, 3D, HDR, location, purchased); sort by relevance or popularity. Ask in another language and country (`language`, `country`) for what YouTube shows there. A result's position is its rank in the search, across pages. Follow `next` for the following page. For one video whole (its description, likes, tags), use youtube/videos/get; for a channel's own videos, youtube/videos/list; for channels by name, youtube/channels/search.

## Call

```bash
curl https://api.lobstr.io/v2/run \
  -H "Authorization: Bearer $LOBSTR_API_KEY" \
  -H "content-type: application/json" \
  -d '{"source": "youtube", "operation": "videos/search", "options": {"query": "n8n tutorial", "upload_date": "this_month", "duration": "over_20_minutes"}}'
```

It answers:

```json
{"object": "run", "status": "succeeded", "count": 20, "has_more": true, "next": {"source": "youtube", "operation": "videos/search", "options": {...}},
 "cost": {"credits": 1}, "balance": {"credits": 9990}, "results": [...]}
```

`cost` and `balance` are objects: a call's credits are `cost.credits`. `results` holds the records (below). `next` is the whole call for the following page: send it as it is; `null` on the last page.

Beside `options`, the call takes:

| Parameter | Type | Description |
|---|---|---|
| `fields` | array of string | The record fields to keep, by path: inside an object with a dot (`ids.video_id`), in each item of a list with `[]` (`collaborators[].id`, or with a dot: `collaborators.id`); `object`, `id` and `position` always come. Left out: every field. |
| `limit` | integer | Only the first N records of this call (1 to 1000), in the call's order; the call costs the same, and `next` keeps the limit. Left out: every record. |

## Options

| Option | Type | Required | Default | Description |
|---|---|---|---|---|
| `query` | string | yes |  | Words to search for, as typed in YouTube's search box. |
| `type` | `all`, `videos`, `shorts` |  | `"all"` | What the search finds: all, the search's own mix of videos and shorts (the shorts among the results say `is_short`); videos, videos only; shorts, shorts only. Channels are searched with youtube/channels/search. |
| `upload_date` | `any`, `today`, `this_week`, `this_month`, `this_year` |  | `"any"` | How recently the videos were uploaded, as the panel's "Upload date" filter. |
| `duration` | `any`, `under_3_minutes`, `3_to_20_minutes`, `over_20_minutes` |  | `"any"` | The videos' length, as the panel's "Duration" filter. |
| `features` | array |  |  | What the videos must have, all of them, as the panel's "Features": live (live now), 4k, hd, subtitles (subtitles or closed captions), creative_commons (under a Creative Commons licence), 360 (360°), vr180, 3d, hdr, location (with a place), purchased (bought by the visitor: signed out, none). |
| `sort` | `relevance`, `popularity` |  | `"relevance"` | The order of the videos: relevance, YouTube's own search order; popularity, YouTube's ranking of the most popular, not views alone. The panel's old order by upload date is gone, and the API answers it in relevance's order (03/12): for the latest videos, filter by `upload_date`. |
| `language` | string |  | `"en"` | The language YouTube speaks to the visitor (en, fr, de, es, pt-BR, ja...): the texts of the records, dates, counts and badges, are written in it ("11 months ago", "il y a 11 mois"); the counts are read in it. |
| `country` | string |  | `"US"` | The visitor's country, two letters (US, GB, FR, IN...), whose people YouTube searches for. |
| `cursor` | string |  |  | Where to go on, from `next` in an answer, as it is: opaque, and only for the search it was given with (otherwise `invalid_cursor`). |

## Record

Each item of `results`. Every field is always present, `null` when the site gives nothing.

| Field | Type | Description |
|---|---|---|
| `object` | `"video"` |  |
| `position` | integer | The video's rank in the search, across pages. |
| `id` | string | The video's id on YouTube, 11 characters, as in its address. |
| `ids` | object |  |
| `ids.video_id` | string |  |
| `ids.channel_id` | string | null | Its channel's id (UC...). |
| `url` | string | The video's page; a short's is its /shorts/ address. |
| `title` | string | null |  |
| `description_snippet` | string | null | The lines of its description the result shows (its start, or the part holding the words searched), cut by YouTube with "..."; null when the result shows none. The whole description is youtube/videos/get's. |
| `duration_seconds` | integer | null | Its length; null for a live in progress, and for a short of a shorts search answered as a grid. |
| `duration_text` | string | null | Its length as shown (3:35:08). |
| `views` | integer | null | Its views, as the result writes them in full ("1,352,247 views"); null for a live in progress, whose viewers are `watching`. A short of a shorts search answered as a grid has them rounded ("52K views" is 52000). |
| `watching` | integer | null | The viewers of a live in progress, now; null otherwise. |
| `published_text` | string | null | When it was put online, as YouTube tells a visitor, in `language` ("11 months ago", "Streamed 2 days ago"); null for a live in progress. A short of a shorts search answered as a grid says it shorter ("19h ago"). |
| `is_live` | boolean | A live in progress. |
| `is_upcoming` | boolean | A live or a premiere to come. |
| `scheduled_at` | string | null (date-time) | When an upcoming one starts. |
| `is_short` | boolean | A YouTube Short. |
| `badges` | array of string | The labels under the result (4K, CC, New, LIVE...), in `language`: two at most (03/12), so a video filtered by subtitles can show "New" and "4K" without "CC". |
| `channel` | object | null | The channel that published it; for a video made by several, the first of them (all in `collaborators`). Null for a short of a shorts search answered as a grid, whose tile does not name it (youtube/videos/get does). |
| `channel.id` | string | null | The channel's id (UC...). |
| `channel.title` | string | null |  |
| `channel.handle` | string | null | Its @handle. |
| `channel.url` | string | null | Its page. |
| `channel.is_verified` | boolean | YouTube's verified badge. |
| `channel.is_artist` | boolean | An official artist channel's badge. |
| `channel.thumbnails` | array | Its avatar. |
| `channel.thumbnails[].url` | string |  |
| `channel.thumbnails[].width` | integer | null |  |
| `channel.thumbnails[].height` | integer | null |  |
| `collaborators` | array | The channels that made the video together, when YouTube says there are several (a collaboration), each with its subscribers; empty otherwise. |
| `collaborators[].id` | string | null |  |
| `collaborators[].title` | string | null |  |
| `collaborators[].handle` | string | null |  |
| `collaborators[].url` | string | null |  |
| `collaborators[].subscribers` | integer | null | Its subscribers, rounded as YouTube shows them (774K is 774000). |
| `collaborators[].subscribers_text` | string | null | As shown (774K subscribers). |
| `collaborators[].is_verified` | boolean |  |
| `collaborators[].thumbnails` | array |  |
| `collaborators[].thumbnails[].url` | string |  |
| `collaborators[].thumbnails[].width` | integer | null |  |
| `collaborators[].thumbnails[].height` | integer | null |  |
| `chapters` | array | The chapters the result shows, for the videos YouTube shows them for; empty otherwise. YouTube shows either the chapters or `ai_summary`, not both. |
| `chapters[].title` | string | null |  |
| `chapters[].start_seconds` | integer | null |  |
| `chapters[].time_text` | string | null | Where it starts, as shown (4:50). |
| `chapters[].is_match` | boolean | A chapter that matches the words searched, as YouTube marks them (several can: 9 of a video's chapters on 03/12); the result's "Matching chapter" is the first, where a click on the result starts the video. |
| `chapters[].thumbnails` | array |  |
| `chapters[].thumbnails[].url` | string |  |
| `chapters[].thumbnails[].width` | integer | null |  |
| `chapters[].thumbnails[].height` | integer | null |  |
| `ai_summary` | string | null | YouTube's own AI-generated summary of the video, as the result shows it in place of the chapters ("AI-generated video summary", which YouTube says to check: its AI can be wrong), its paragraphs apart; null when it shows none (5 videos of 34 on two pages, 03/12). |
| `thumbnails` | array | The video's thumbnail in its sizes, the largest last. |
| `thumbnails[].url` | string |  |
| `thumbnails[].width` | integer | null |  |
| `thumbnails[].height` | integer | null |  |
| `moving_thumbnail` | object | null | The few seconds of the video the result plays on hover (an animated WebP), when it has them. |
| `moving_thumbnail.url` | string |  |
| `moving_thumbnail.width` | integer | null |  |
| `moving_thumbnail.height` | integer | null |  |
| `source_url` | string | The results page of youtube.com for this search. |
| `observed_at` | string (date-time) |  |

Example:

```json
{
  "object": "video",
  "position": 1,
  "id": "n8nTutor1al",
  "ids": {
    "video_id": "n8nTutor1al",
    "channel_id": "UCa1b2c3d4e5f6g7h8i9j0kL"
  },
  "url": "https://www.youtube.com/watch?v=n8nTutor1al",
  "title": "n8n Tutorial for Beginners: Build Your First Workflow",
  "description_snippet": "Learn n8n from scratch and build your first automation in under an hour ...",
  "duration_seconds": 2843,
  "duration_text": "47:23",
  "views": 18342,
  "watching": null,
  "published_text": "2 weeks ago",
  "is_live": false,
  "is_upcoming": false,
  "scheduled_at": null,
  "is_short": false,
  "badges": [
    "4K",
    "CC"
  ],
  "channel": {
    "id": "UCa1b2c3d4e5f6g7h8i9j0kL",
    "title": "Automation Academy",
    "handle": "@automationacademy",
    "url": "https://www.youtube.com/@automationacademy",
    "is_verified": true,
    "is_artist": false,
    "thumbnails": [
      {
        "url": "https://yt3.ggpht.com/automation-academy=s68-c-k-c0x00ffffff-no-rj",
        "width": 68,
        "height": 68
      }
    ]
  },
  "collaborators": [],
  "chapters": [
    {
      "title": "Introduction",
      "start_seconds": 0,
      "time_text": "0:00",
      "is_match": false,
      "thumbnails": [
        {
          "url": "https://i.ytimg.com/vi/n8nTutor1al/hqdefault_0.jpg",
          "width": 336,
          "height": 188
        }
      ]
    },
    {
      "title": "Your first trigger",
      "start_seconds": 312,
      "time_text": "5:12",
      "is_match": true,
      "thumbnails": [
        {
          "url": "https://i.ytimg.com/vi/n8nTutor1al/hqdefault_312000.jpg",
          "width": 336,
          "height": 188
        }
      ]
    }
  ],
  "ai_summary": null,
  "thumbnails": [
    {
      "url": "https://i.ytimg.com/vi/n8nTutor1al/hq720.jpg",
      "width": 360,
      "height": 202
    },
    {
      "url": "https://i.ytimg.com/vi/n8nTutor1al/hq720.jpg",
      "width": 720,
      "height": 404
    }
  ],
  "moving_thumbnail": {
    "url": "https://i.ytimg.com/an_webp/n8nTutor1al/mqdefault_6s.webp",
    "width": 320,
    "height": 180
  },
  "source_url": "https://www.youtube.com/results?search_query=n8n+tutorial&sp=EgQIBBgC",
  "observed_at": "2026-12-03T12:00:00Z"
}
```

## Price

1 credit a call, one page of about 20 videos. An empty page and a failed call are free.

## Errors

| Code | Status | Retry | Message |
|---|---|---|---|
| `ip_blocked` | 503 | yes | YouTube slowed down the IPs the call tried (429). Retry in a minute; failed calls are free. |
| `invalid_input` | 422 | no | Pass the words to search for, and the filters as the search's panel offers them: a type, an upload date, a duration, features, an order, a language (en) and a country (US). |
| `site_unavailable` | 503 | yes | YouTube did not answer properly; retry later (not charged). |
| `unexpected_answer` | 424 | no | YouTube answered in a shape we do not read yet; we are told and fix it (not charged). |
| `missing_api_key` | 401 | no | No API key: send it as `Authorization: Bearer <key>`. |
| `invalid_api_key` | 401 | no | The key is not valid, or not anymore. |
| `insufficient_credits` | 402 | no | The call costs more credits than are left. |
| `unknown_operation` | 404 | no | No such source and operation in the catalog. |
| `timeout` | 408 | yes | The call did not finish within its deadline (not charged). |
| `invalid_body` | 422 | no | The body is not a call: source, operation, options. |
| `invalid_options` | 422 | no | An option is missing or out of its contract; `param` names it. |
| `invalid_idempotency_key` | 400 | no | The Idempotency-Key header is not printable ASCII, or too long. |
| `concurrency_limit` | 429 | yes | The plan's calls at a time are all in progress (Free 1, Starter 2, Pro 10, Team 50); retry when one has finished (not charged, never queued). |
| `service_busy` | 503 | yes | Too many calls at once on the account; retry in a few seconds. |
| `balance_unavailable` | 503 | yes | The balance could not be read; retry in a few seconds. |

## Changelog

- **1.0.1** (2026-12-03): A shorts search (`type: shorts`) gave empty pages when YouTube answered it as a grid of shorts, 25 a page, one of its two layouts that day: the grid's shorts are now the results, each with its title, views (rounded), age, badge and thumbnails, without its channel or duration, which the grid does not show (youtube/videos/get has them).
- **1.0.0** (2026-12-03): First version: one page of a YouTube search, signed out, by words, type (videos or shorts), upload date, duration and features, sorted by relevance or popularity, in a language and a country; each video with its channel and collaborators, views or viewers, duration, date, live, upcoming and short marks, badges, chapters (the one matching the words marked), YouTube's AI summary when it shows one, and thumbnails.

Schema: https://api.lobstr.io/v2/catalog/youtube/videos/search · All operations: https://api.lobstr.io/v2/catalog.md
