# Search

Search YouTube for videos, channels, and playlists.

- Platform: [YouTube](https://docs.upscrape.com/docs/platforms/youtube)
- Capability ID: `youtube.search.query`
- Cost: 1 credit per request
- Maximum runtime: 60 seconds
- Execute endpoint: `POST https://data.upscrape.com/execute`

## Request

Use the exact public capability ID in the shared execute envelope.

```bash
curl --request POST \
  --url https://data.upscrape.com/execute \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Prefer: wait=30" \
  --data '{
  "input": {
    "query": "golang tutorial"
  },
  "capability": "youtube.search.query"
}'
```

## Input

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `filter` | `string` | No | Filter supplied for this request. Allowed values: `videos`, `channels`, `playlists`, `live`, `shorts`, `today`, `week`, `month`, `year`. |
| `limit` | `integer` | No | Maximum number of results to return. |
| `max_pages` | `integer` | No | Max pages supplied for this request. |
| `query` | `string` | Yes | Search query |

### Example input

```json
{
  "query": "golang tutorial"
}
```

## Response

Successful output is returned in `results[0].data`. Raw platform output is intentionally open-ended and may evolve with the upstream source.

### Illustrative sample output

This redacted fixture is an example, not a fixed response schema.

```json
{
  "pages": 10,
  "query": "golang tutorial",
  "results": [
    {
      "channel": "TechWorld with Nana",
      "channel_id": "UCdngmbVKX1Tgre699-XLlUA",
      "duration": "3:24:59",
      "published": "4 years ago",
      "thumbnails": [
        {
          "height": 202,
          "url": "https://i.ytimg.com/vi/yyUHQIec83I/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLB4_rRdt_HVFu53B1PXgj63C1oscA",
          "width": 360
        },
        {
          "height": 404,
          "url": "https://i.ytimg.com/vi/yyUHQIec83I/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLD6EOnmQQCwati8mehjx9ujPnlNTw",
          "width": 720
        }
      ],
      "title": "Golang Tutorial for Beginners | Full Go Course",
      "type": "video",
      "video_id": "yyUHQIec83I",
      "views": "2,444,656 views"
    },
    {
      "channel": "Alex Mux",
      "channel_id": "UCr3L56DsMxhNtHqtm2AIsMw",
      "duration": "1:07:53",
      "published": "2 years ago",
      "thumbnails": [
        {
          "height": 202,
          "url": "https://i.ytimg.com/vi/8uiZC0l4Ajw/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLALu_rNLsvRX2gSJWHau0b4sSJ_lA",
          "width": 360
        },
        {
          "height": 404,
          "url": "https://i.ytimg.com/vi/8uiZC0l4Ajw/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLD1yhA49oKS0DqwMqNZeccSwdLGrw",
          "width": 720
        }
      ],
      "title": "Learn GO Fast: Full Tutorial",
      "type": "video",
      "video_id": "8uiZC0l4Ajw",
      "views": "1,079,544 views"
    },
    {
      "channel": "freeCodeCamp.org",
      "channel_id": "UC8butISFwT-Wl7EV0hUK0BQ",
      "duration": "9:32:48",
      "published": "3 years ago",
      "thumbnails": [
        {
          "height": 202,
          "url": "https://i.ytimg.com/vi/un6ZyFkqFKo/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLA5xVRBNCjb7uMn07Q6h1cDZIukBQ",
          "width": 360
        },
        {
          "height": 404,
          "url": "https://i.ytimg.com/vi/un6ZyFkqFKo/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLCZH-eqLDxu9tLVChBWxxQVXasSUw",
          "width": 720
        }
      ],
      "title": "Go Programming – Golang Course with Bonus Projects",
      "type": "video",
      "video_id": "un6ZyFkqFKo",
      "views": "1,476,385 views"
    }
  ],
  "results_count": 185
}
```
### Illustrative output fields

Derived from the sample above for orientation only. These fields are not a fixed response schema.

| Path | Observed type | Example |
| --- | --- | --- |
| `pages` | `integer` | 10 |
| `query` | `string` | golang tutorial |
| `results` | `array` | 3 items |
| `results` | `array` | 3 items |
| `results_count` | `integer` | 185 |

## Execution behavior

A `200` response completed inline. A `202` response was queued; poll `GET /jobs/{id}` until the job reaches `completed` or `failed`. Use an `Idempotency-Key` when retrying must not create a duplicate logical job.

## Related documentation

- [Authentication](https://docs.upscrape.com/docs/api/authentication)
- [Jobs and results](https://docs.upscrape.com/docs/api/jobs)
- [Errors and retries](https://docs.upscrape.com/docs/api/errors)
- [Idempotency](https://docs.upscrape.com/docs/api/idempotency)
