# YouTube comments viewer API

Read available public YouTube comments and export the current batch as CSV or JSON.

Canonical: https://fetchfox.net/docs/youtube-comments-api

## Request

GET /youtube/comments (query parameters) or POST /youtube/comments (JSON). Authenticate with x-access-key. Keep keys server-side.

Credits: 1 credit per 50 returned comments, minimum 1 including verified empty results. Balance pre-check: 1 per 20 requested comments.

### curl

```
curl --fail-with-body --get 'https://api.fetchfox.net/youtube/comments' \
  -H 'x-access-key: YOUR_KEY' \
  --data-urlencode 'url=https://www.youtube.com/watch?v=VIDEO_ID' \
  --data-urlencode 'limit=20'
```

### JavaScript

```
// Run on your server with FETCHFOX_API_KEY set.
const url = new URL('https://api.fetchfox.net/youtube/comments');
url.searchParams.set('url', 'https://www.youtube.com/watch?v=VIDEO_ID');
url.searchParams.set('limit', '20');
const response = await fetch(url, {
  headers: { 'x-access-key': process.env.FETCHFOX_API_KEY },
  signal: AbortSignal.timeout(130000)
});
if (!response.ok) throw new Error('HTTP ' + response.status);
const result = await response.json();
if (!result.success) throw new Error('Request unsuccessful');
console.log(result.data);
```

### Python

```
import json, os
from urllib.parse import urlencode
from urllib.request import Request, urlopen

query = urlencode({"url":"https://www.youtube.com/watch?v=VIDEO_ID","limit":20})
request = Request('https://api.fetchfox.net/youtube/comments?' + query,
    headers={'x-access-key': os.environ['FETCHFOX_API_KEY']})
with urlopen(request, timeout=130) as response:
    result = json.load(response)
if not result.get('success'):
    raise RuntimeError('Request unsuccessful')
print(result['data'])
```

## Inputs and limits

Requests up to 20 comments for 1 credit on success. Coverage can be partial; hidden comments and all replies are not included. YouTube does not provide a continuation cursor in this endpoint.

REST and MCP accept limits from 1 to 100, default 20. Browser viewers request 20. Each new request is billed separately; downloading a current browser result does not make another request.

## Interpret source fields

data.comments returns available text and author fields. Numeric IDs stay strings; do not coerce them to spreadsheet numbers. Unknown likes, reply counts and dates stay null. Collection status describes the available sample, not complete coverage.

YouTube keeps source relativeTime and leaves exact date null when it cannot establish a timestamp. A source ID can also be null; IDs and dates are never invented.

## Related pages

- https://fetchfox.net/tools/youtube-comments-viewer

- https://fetchfox.net/docs

- https://fetchfox.net/pricing

