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

# YouTube search

> Read a YouTube search results page with the search in search_query as JSON with the youtube-search parser. $1 per 1,000 calls.

Reads a YouTube search results page with the search in search\_query and returns a list of videos as JSON.

## Make a request

Send the page's URL to [scrape](https://docs.stophy.dev/api-reference/endpoint/scrape.md) with a `json` format that names the parser. This parser works without an API key when you send no options, up to 10 calls a minute and 50 calls a day per IP address. See [Rate limits](https://docs.stophy.dev/production/rate-limits.md). To lift the limits, get an API key in the [Quickstart](https://docs.stophy.dev/quickstart).

```bash cURL theme={null}
curl -X POST https://api.stophy.dev/v1/scrape \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://www.youtube.com/results?search_query=lofi+beats","formats":[{"type":"json","parser":"youtube-search"}]}'
```

```typescript TypeScript theme={null}
const response = await fetch("https://api.stophy.dev/v1/scrape", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.STOPHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://www.youtube.com/results?search_query=lofi+beats",
    formats: [{ type: "json", parser: "youtube-search" }],
  }),
});
console.log(await response.json());
```

```python Python theme={null}
import os

import requests

response = requests.post(
    "https://api.stophy.dev/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['STOPHY_API_KEY']}"},
    json={
        "url": "https://www.youtube.com/results?search_query=lofi+beats",
        "formats": [{"type": "json", "parser": "youtube-search"}],
    },
)
print(response.json())
```

## Read the response

The parser's data is in `data.json`. Its fields include `results`, `cursor`, `page` and `total`. This sample is cut to the first items.

```json theme={null}
{
  "success": true,
  "data": {
    "json": {
      "results": [
        {
          "id": "RDEMB4pXSfqexQjAYE27XBWebA",
          "url": "https://www.youtube.com/playlist?list=RDEMB4pXSfqexQjAYE27XBWebA",
          "title": "Mix - Lo-Fi Beats",
          "description": null,
          "author": {
            "id": null,
            "name": null,
            "handle": null,
            "url": null,
            "avatarUrl": null
          },
          "publishedAt": null,
          "durationSeconds": null,
          "views": null,
          "likes": null,
          "comments": null,
          "thumbnailUrl": "https://i.ytimg.com/vi/xVf4Zk8CBj0/hq720.jpg?sqp=-oaymwExCNAFEJQDSFryq4qpAyMIARUAAIhCGAHwAQH4Af4JgALQBYoCDAgAEAEYOSBhKG…",
          "hashtags": [],
          "type": "playlist",
          "videoCount": null
        }
      ],
      "cursor": "seen_88e6f353-7668-4a45-be2f-ee006bafacc9",
      "page": null,
      "total": null
    }
  }
}
```

## Options

Send options in the `options` object of the `json` format.

| Option | What it does |
| - | - |
| `type` | Leave out for videos, channels and playlists. Use shorts for Shorts. |
| `cursor` | The cursor from the previous response. Send it as is. |

It also takes `duration`, `uploadDate`, `features` and `prioritize`.

## Price

\$1 per 1,000 calls. Works without an API key, within the free limits. See [Pricing](https://docs.stophy.dev/account/pricing.md).

## Limits and errors

* The URL must be a YouTube search results page with the search in search\_query. Any other URL fails with `invalidRequest`.
* To read the next page, send the `cursor` from the response as the `cursor` option. Paging needs an API key.
* The answer comes back in `data.json`. If the page cannot be read, the call fails with an error code from [Errors](https://docs.stophy.dev/api-reference/errors.md).

## Related

* [Pre-built parsers](https://docs.stophy.dev/scrape/prebuilt-parsers) lists every parser.
* [Scrape](https://docs.stophy.dev/scrape/overview) has the options every scrape takes.
* [YouTube video](https://docs.stophy.dev/scrape/prebuilt-parsers/video/youtube-video.md)
* [YouTube transcript](https://docs.stophy.dev/scrape/prebuilt-parsers/video/youtube-transcript.md)
* [YouTube comments](https://docs.stophy.dev/scrape/prebuilt-parsers/video/youtube-comments.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.