# YouTube Search

Search for videos on YouTube with customizable result limits.

- **Documentation:** [https://scrappa.co/docs/youtube-api/youtube_search](https://scrappa.co/docs/youtube-api/youtube_search)
- **API group:** YouTube API
- **Endpoint:** `GET https://scrappa.co/api/youtube/search`

## Authentication

Send your Scrappa API key in the `X-API-KEY` request header. Paid endpoints also support accountless x402 payments when called without an API key.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | Yes | Search query |
| `limit` | integer | No | Number of results (default: 10, max: 20) |
| `page` | integer | No | Page number (default: 1, max: 10) |
| `continuation` | string | No | Token for pagination from previous response |
| `type` | string | No | Filter by content type: video, channel, playlist, movie, all (default: all). |
| `hl` | string | No | Language code (e.g., en). |
| `gl` | string | No | Country code (e.g., US). |
| `order` | string | No | Sort order: date, rating, relevance, viewCount. |
| `videoDuration` | string | No | Filter by duration: short, medium, long. |
| `publishedAfter` | string | No | Return videos published after a date/time (best-effort; any valid date string, RFC3339 recommended). |
| `publishedBefore` | string | No | Return videos published before a date/time (best-effort; any valid date string, RFC3339 recommended). |
| `safeSearch` | string | No | Content filtering: moderate, none, strict. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/youtube/search?query=programming+tutorial"
```

## Example response

```json
{
    "results": [
        {
            "type": "video",
            "id": "dQw4w9WgXcQ",
            "title": "Rick Astley - Never Gonna Give You Up (Official Video)",
            "description": "The official video for Never Gonna Give You Up by Rick Astley.",
            "thumbnail": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
            "duration": "3:33",
            "viewCount": "1.7B views",
            "publishedTime": "16 years ago",
            "channel": {
                "id": "UCuAXFkgsw1L7xaCfnd5JJOw",
                "name": "Rick Astley",
                "thumbnail": "https://yt3.ggpht.com/example.jpg",
                "verified": false,
                "isVerifiedArtist": true,
                "url": "https://www.youtube.com/@RickAstleyYT"
            },
            "badges": [],
            "isLive": false,
            "isShort": false,
            "isPremium": false
        }
    ],
    "pagination": {
        "continuationToken": "eyJ...",
        "hasMore": true,
        "page": 1,
        "pageSize": 10
    },
    "query": "programming tutorial",
    "filters": {
        "type": "all",
        "sort": "relevance",
        "hl": "en",
        "gl": "US"
    }
}
```

## More Scrappa resources

- [API documentation](https://scrappa.co/docs)
- [Full LLM-readable API reference](https://scrappa.co/llms-full.txt)
- [OpenAPI specification](https://scrappa.co/docs/api.json)
- [Pricing](https://scrappa.co/pricing)
