# Search

Search videos, Shorts, channels, playlists and live broadcasts using the legacy filter or composable type, upload_date, duration and sort selectors.

- 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 $UPSCRAPE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Prefer: wait=30" \
  --data '{
  "input": {
    "filter": "videos",
    "limit": 40,
    "max_pages": 3,
    "query": "noise cancelling headphones review"
  },
  "capability": "youtube.search.query"
}'
```

## Input


| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `duration` | `string` | No | Restrict video results by duration. Allowed values: `short`, `long`, `medium`. |
| `filter` | `string` | No | Legacy single selector. Do not combine with type, upload_date, duration or sort. Allowed values: `videos`, `channels`, `playlists`, `live`, `shorts`, `today`, `week`, `month`, `year`. |
| `limit` | `integer` | No | Maximum number of results to return. From 1 to 500. Default: `100`. |
| `max_pages` | `integer` | No | Maximum number of result pages to fetch. From 1 to 100. Default: `5`. |
| `query` | `string` | Yes | Search query |
| `sort` | `string` | No | Order results by the source's native sort. Allowed values: `relevance`, `rating`, `upload_date`, `view_count`. |
| `type` | `string` | No | Restrict results to one content type. Allowed values: `video`, `channel`, `playlist`, `movie`. |
| `upload_date` | `string` | No | Restrict results to a recent upload window. Allowed values: `hour`, `today`, `week`, `month`, `year`. |

### Example input

```json
{
  "filter": "videos",
  "limit": 40,
  "max_pages": 3,
  "query": "noise cancelling headphones review"
}
```

## 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 example shows one response. Values and optional fields vary with the data available.

```json
{
  "has_more": true,
  "pages": 2,
  "query": "noise cancelling headphones review",
  "results": [
    {
      "channel": "Marques Brownlee",
      "channel_id": "UCBJycsmduvYEL83R_U4JriQ",
      "duration": "9:17",
      "duration_seconds": 557,
      "published": "1 year ago",
      "thumbnails": [
        {
          "height": 202,
          "url": "https://i.ytimg.com/vi/XbXXKhfvSF0/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLB87KfIDb7ytn6HL5hPxD88M_ESeA",
          "width": 360
        },
        {
          "height": 404,
          "url": "https://i.ytimg.com/vi/XbXXKhfvSF0/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLCXavhz42l_gDmYPTgJblsuF6v9fg",
          "width": 720
        }
      ],
      "title": "Sony WH-1000XM6 Review: Back on the Throne!",
      "type": "video",
      "video_id": "XbXXKhfvSF0",
      "view_count": 4925722,
      "views": "4,925,722 views"
    },
    {
      "channel": "Mark Ellis Reviews",
      "channel_id": "UCwwuSBYcErVlOpveYubHv4g",
      "duration": "18:37",
      "duration_seconds": 1117,
      "published": "2 months ago",
      "thumbnails": [
        {
          "height": 202,
          "url": "https://i.ytimg.com/vi/ljV1iOJmE_E/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLCpNkS6Reob0ie3m6SvCvkpwa34XQ",
          "width": 360
        },
        {
          "height": 404,
          "url": "https://i.ytimg.com/vi/ljV1iOJmE_E/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLBj_hP1aVy6il25dZS8kD2m0kqdbQ",
          "width": 720
        }
      ],
      "title": "The Only ANC Headphones Worth Buying in 2026",
      "type": "video",
      "video_id": "ljV1iOJmE_E",
      "view_count": 132845,
      "views": "132,845 views"
    },
    {
      "channel": "RTINGS Audio",
      "channel_id": "UCz4geqN2YY6gktLikAKMvlw",
      "duration": "8:59",
      "duration_seconds": 539,
      "published": "6 months ago",
      "thumbnails": [
        {
          "height": 202,
          "url": "https://i.ytimg.com/vi/-eLeP7MdoHI/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLCyD0ak8GBG-8knA_YNCw_wBUEkcg",
          "width": 360
        },
        {
          "height": 404,
          "url": "https://i.ytimg.com/vi/-eLeP7MdoHI/hq720.jpg?sqp=-[redacted:token]==&rs=AOn4CLBmbWkLjQOds6j5pUMz0ayejFe40A",
          "width": 720
        }
      ],
      "title": "The Best Noise Cancelling Headphones To Buy In 2026",
      "type": "video",
      "video_id": "-eLeP7MdoHI",
      "view_count": 77487,
      "views": "77,487 views"
    }
  ],
  "results_count": 40
}
```
### Illustrative output fields

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

| Path | Observed type | Example |
| --- | --- | --- |
| `has_more` | `boolean` | true |
| `pages` | `integer` | 2 |
| `query` | `string` | noise cancelling headphones review |
| `results` | `array` | 3 items |
| `results` | `array` | 3 items |
| `results_count` | `integer` | 40 |

## 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)
