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

> Read a YouTube video link as JSON with the youtube-comments parser. $1 per 1,000 calls. Send the page to scrape. Examples in cURL, TypeScript and Python.

Reads a YouTube video link: watch, youtu.be, shorts or live, and returns a list of comments 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/watch?v=dQw4w9WgXcQ","formats":[{"type":"json","parser":"youtube-comments"}]}'
```

```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/watch?v=dQw4w9WgXcQ",
    formats: [{ type: "json", parser: "youtube-comments" }],
  }),
});
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/watch?v=dQw4w9WgXcQ",
        "formats": [{"type": "json", "parser": "youtube-comments"}],
    },
)
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": "UgyEnXfdC-umwvTt8JF4AaABAg",
          "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ&lc=UgyEnXfdC-umwvTt8JF4AaABAg",
          "author": {
            "id": "0",
            "name": "Example user",
            "handle": "example_user",
            "url": "https://example.com/example_user",
            "avatarUrl": null
          },
          "text": "Gonna flag this for nudity so I can rick roll the YouTube staff",
          "publishedAt": "2020-01-01T00:00:00.000Z",
          "likes": 569000,
          "replies": 726,
          "parentId": null,
          "isPinned": false,
          "isHearted": false,
          "isChannelOwner": false,
          "repliesCursor": "Eg0SC2RRdzR3OVdnWGNRGAYygwEaUBIaVWd5RW5YZmRDLXVtd3ZUdDhKRjRBYUFCQWciAggAKhhVQ3VBWEZrZ3N3MUw3eGFDZm5kNUpKT3cyC2RRdzR3OVd…"
        }
      ],
      "cursor": "Eg0SC2RRdzR3OVdnWGNRGAYy_gIK1AJnZXRfcmFua2VkX3N0cmVhbXMtLUNxWUJDSUFFRlJlMzBUZ2Ftd0VLbGdFSTJGOFFnQVFZQnlLTEFWdDhhbWV6S3llMWJCOXJJR3BXbmlPZVpDbFJpRDBvc2JZX0FPY...",
      "page": null,
      "total": null
    }
  }
}
```

## Options

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

| Option | What it does |
| - | - |
| `comment` | A comment's repliesCursor from an earlier response. Returns that comment's replies. |
| `cursor` | The cursor from the previous response. Send it as is. |

It also takes `sort`.

## 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 video link: watch, youtu.be, shorts or live. 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 search](https://docs.stophy.dev/scrape/prebuilt-parsers/video/youtube-search.md)
* [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)


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