> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapebadger.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Search YouTube for videos, channels, playlists, or movies.

## Query Parameters

<ParamField query="query" type="string" required>
  Search keywords.
</ParamField>

<ParamField query="type" type="string" default="all">
  Restrict results to a single result type.

  | Value      | Description                |
  | ---------- | -------------------------- |
  | `all`      | All result types (default) |
  | `video`    | Videos only                |
  | `channel`  | Channels only              |
  | `playlist` | Playlists only             |
  | `movie`    | Movies only                |
</ParamField>

<ParamField query="sort_by" type="string" default="relevance">
  Sort order for results.

  | Value       | Description            |
  | ----------- | ---------------------- |
  | `relevance` | Best match (default)   |
  | `date`      | Most recently uploaded |
  | `views`     | Most viewed            |
  | `rating`    | Highest rated          |
</ParamField>

<ParamField query="upload_date" type="string">
  Filter by upload recency: `hour`, `today`, `week`, `month`, or `year`.
</ParamField>

<ParamField query="duration" type="string">
  Filter by video length: `short` (\< 4 min), `medium` (4-20 min), or `long` (> 20 min).
</ParamField>

<ParamField query="features" type="string">
  Comma-separated feature filters, e.g. `hd,4k,subtitles,live,creative_commons`.
</ParamField>

<ParamField query="gl" type="string" default="US">
  Content region (ISO 3166-1 alpha-2 country code). Examples: `US`, `GB`, `DE`, `JP`.
</ParamField>

<ParamField query="hl" type="string" default="en">
  UI / interface language (BCP-47). Examples: `en`, `de`, `fr`, `ja`.
</ParamField>

<ParamField query="continuation" type="string">
  Continuation token from a previous response to fetch the next page.
</ParamField>

## Response

<ResponseField name="query" type="string">The search query that was executed.</ResponseField>

<ResponseField name="results" type="array">
  Array of matching results (polymorphic, keyed by `type`).

  <Expandable title="SearchResult object">
    <ResponseField name="type" type="string">Result type: `video`, `channel`, `playlist`, `movie`, or `short`.</ResponseField>
    <ResponseField name="position" type="integer">Position on the page (nullable).</ResponseField>
    <ResponseField name="video_id" type="string">Video id (video/short/movie results, nullable).</ResponseField>
    <ResponseField name="title" type="string">Result title (nullable).</ResponseField>
    <ResponseField name="url" type="string">Full URL to the result (nullable).</ResponseField>
    <ResponseField name="thumbnails" type="array">Thumbnail objects with `url`, `width`, `height`.</ResponseField>
    <ResponseField name="thumbnail" type="string">Best/primary thumbnail URL (nullable).</ResponseField>
    <ResponseField name="duration" type="string">Human-readable duration, e.g. `3:32` (nullable).</ResponseField>
    <ResponseField name="length_seconds" type="integer">Duration in seconds (nullable).</ResponseField>
    <ResponseField name="view_count" type="integer">View count (nullable).</ResponseField>
    <ResponseField name="view_count_text" type="string">View count as displayed, e.g. `1.6B views` (nullable).</ResponseField>
    <ResponseField name="short_view_count_text" type="string">Abbreviated view count (nullable).</ResponseField>
    <ResponseField name="published_time_text" type="string">Relative publish time, e.g. `13 years ago` (nullable).</ResponseField>
    <ResponseField name="published_at" type="string">ISO 8601 publish timestamp (nullable).</ResponseField>
    <ResponseField name="published_utc" type="number">Unix publish timestamp (nullable).</ResponseField>
    <ResponseField name="description_snippet" type="string">Short description snippet (nullable).</ResponseField>
    <ResponseField name="badges" type="array">Result badges, e.g. `4K`, `CC`.</ResponseField>
    <ResponseField name="extensions" type="array">Extra metadata strings.</ResponseField>
    <ResponseField name="is_live" type="boolean">Whether the video is live (nullable).</ResponseField>
    <ResponseField name="is_short" type="boolean">Whether the result is a Short (nullable).</ResponseField>
    <ResponseField name="is_members_only" type="boolean">Whether the video is members-only (nullable).</ResponseField>
    <ResponseField name="channel_id" type="string">Associated channel id (nullable).</ResponseField>
    <ResponseField name="channel_name" type="string">Channel name (nullable).</ResponseField>
    <ResponseField name="channel_url" type="string">Channel URL (nullable).</ResponseField>
    <ResponseField name="channel_thumbnail" type="string">Channel avatar URL (nullable).</ResponseField>
    <ResponseField name="channel_is_verified" type="boolean">Whether the channel is verified (nullable).</ResponseField>
    <ResponseField name="subscriber_count_text" type="string">Subscriber count text (channel results, nullable).</ResponseField>
    <ResponseField name="number_of_subscribers" type="integer">Subscriber count (channel results, nullable).</ResponseField>
    <ResponseField name="video_count_text" type="string">Video count text (channel results, nullable).</ResponseField>
    <ResponseField name="channel_username" type="string">Channel `@handle` (channel results, nullable).</ResponseField>
    <ResponseField name="is_verified" type="boolean">Whether the channel is verified (channel results, nullable).</ResponseField>
    <ResponseField name="playlist_id" type="string">Playlist id (playlist results, nullable).</ResponseField>
    <ResponseField name="video_count" type="integer">Number of videos (playlist results, nullable).</ResponseField>
    <ResponseField name="first_video_id" type="string">First video id (playlist results, nullable).</ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total_results" type="integer">Reported total result count (nullable).</ResponseField>
<ResponseField name="estimated_results" type="integer">Estimated result count (nullable).</ResponseField>
<ResponseField name="chips" type="array">Filter chips / refinements with `title`, `is_selected`, `continuation`.</ResponseField>
<ResponseField name="did_you_mean" type="string">Spelling suggestion, if any (nullable).</ResponseField>
<ResponseField name="showing_results_for" type="string">Corrected query actually searched (nullable).</ResponseField>
<ResponseField name="refinements" type="array">Suggested query refinements.</ResponseField>
<ResponseField name="related_searches" type="array">Related search objects.</ResponseField>
<ResponseField name="continuation" type="string">Token to fetch the next page (nullable when no more pages).</ResponseField>

### Example Response

```json theme={null}
{
  "query": "lofi hip hop",
  "results": [
    {
      "type": "video",
      "position": 1,
      "video_id": "jfKfPfyJRdk",
      "title": "lofi hip hop radio - beats to relax/study to",
      "url": "https://www.youtube.com/watch?v=jfKfPfyJRdk",
      "thumbnail": "https://i.ytimg.com/vi/jfKfPfyJRdk/hqdefault.jpg",
      "duration": null,
      "view_count_text": "Live · 42K watching",
      "published_time_text": "Streamed 2 years ago",
      "channel_id": "UCSJ4gkVC6NrvII8umztf0Ow",
      "channel_name": "Lofi Girl",
      "channel_is_verified": true,
      "is_live": true,
      "is_short": false
    }
  ],
  "estimated_results": 1240000,
  "chips": [
    { "title": "All", "is_selected": true, "continuation": null },
    { "title": "Videos", "is_selected": false, "continuation": "EgIQAQ..." }
  ],
  "continuation": "EpcDEgxsb2ZpIGhpcCBob3A..."
}
```

<Note>
  Each search request costs **5 credits**. Failed requests are not charged.
</Note>
