# Search YouTube

Search for videos or channels with rich metadata.

Source: https://youtubetranscriptapi.com/docs/api/search

The Search endpoint runs a query against YouTube and returns either video or channel results in a single JSON envelope. Authenticate with `Authorization: Bearer YOUR_API_KEY`. Each successful 200 response charges 4 credits; 4xx errors, 5xx errors, and 429 rate-limits never debit. Set `type=video` for videos with `videoId`, `title`, `channelTitle`, `lengthText`, and `viewCountText`; set `type=channel` for channels with `channelId`, `handle`, and `subscriberCount`. Limit is 1–50 per call. In video results, `channelVerified` and `hasCaptions` are always `null`.

`GET /api/v2/youtube/search` — 4 credits

## Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `q` (required) | `string` | — | Search query, 1–200 characters. |
| `type` | `string` | `video` | Either video or channel. |
| `limit` | `integer` | `20` | Max results (1–50). |

## Example — video search

```bash
curl -X GET "https://youtubetranscriptapi.com/api/v2/youtube/search?q=python+tutorial&type=video&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```json
{
  "results": [
    {
      "type": "video",
      "videoId": "dQw4w9WgXcQ",
      "title": "Rick Astley - Never Gonna Give You Up",
      "channelId": "UCuAXFkgsw1L7xaCfnd5JJOw",
      "channelTitle": "Rick Astley",
      "channelHandle": "@RickAstley",
      "channelVerified": null,
      "lengthText": "3:33",
      "viewCountText": "1.5B views",
      "publishedTimeText": "14 years ago",
      "hasCaptions": null,
      "thumbnails": [
        { "url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/default.jpg", "width": 120, "height": 90 },
        { "url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/mqdefault.jpg", "width": 320, "height": 180 },
        { "url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg", "width": 480, "height": 360 }
      ]
    }
  ],
  "result_count": 10
}
```

## Example — channel search

```bash
curl -X GET "https://youtubetranscriptapi.com/api/v2/youtube/search?q=ted+talks&type=channel&limit=5" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```json
{
  "results": [
    {
      "type": "channel",
      "channelId": "UCAuUUnT6oDeKwE6v1NGQxug",
      "title": "TED",
      "handle": "@TED",
      "url": "https://www.youtube.com/@TED",
      "description": "Official channel...",
      "subscriberCount": "26M subscribers",
      "verified": true,
      "rssUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=UCAuUUnT6oDeKwE6v1NGQxug",
      "thumbnails": []
    }
  ],
  "result_count": 5
}
```
