YouTube Comment Search API

One authenticated GET returns a public YouTube video's comments as JSON — authors, texts, and engagement counters, up to 50 per call.

  • One REST Endpoint
  • Structured Comment Items
  • Adjustable Result Size
  • Works On Any Public Video
  • Predictable Error Codes
  • Samples In Five Languages

Request examples

curl "https://api.agentbody.io/v1/youtube/comments?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdQw4w9WgXcQ&max_results=1" \
  -H "Authorization: Bearer <YOUR_AGENTBODY_API_KEY>"

Response examples

Documented responses from the OpenAPI specification.

Public top-level comments for one YouTube video.

{
  "items": [
    {
      "author": "Example Author",
      "id": "UgkxExample",
      "like_count": 12,
      "reply_count": 2,
      "text": "Great video!"
    }
  ],
  "total": 1,
  "video_id": "dQw4w9WgXcQ"
}

Features

Use the YouTube Comment Search API for audience research, sentiment pipelines, and moderation tooling — video URL in, structured comments out.

One REST Endpoint

Call GET /v1/youtube/comments with a bearer API key and the public video URL. The API returns the comment section as structured JSON — no YouTube Data API quota juggling, no scraping stack to maintain.

Structured Comment Items

Each item carries id, author, text, like_count, and reply_count, and the response reports the video_id and total. Drop items straight into search indexes, sentiment pipelines, or spreadsheets without custom parsing.

Adjustable Result Size

Set max_results from 1 to 50 per call to match your workload — a small sample for a quick check, the full 50 for batch analysis. The gateway may return fewer when the section is smaller than the limit.

Works On Any Public Video

The endpoint reads the public comment section of any public video — no channel ownership or OAuth consent flow. Standard videos and Shorts both resolve through the same request shape.

Predictable Error Codes

Handle failures with documented status codes: 400 for an invalid request, 401 for a missing or bad API key, and 502/503/504 for temporary upstream issues — each maps to a distinct fix or retry action.

Samples In Five Languages

This page generates request examples in curl, JavaScript, Python, Java, and Go directly from the endpoint's OpenAPI definition — adopt the HTTP client your stack already uses.

How to use

Follow these steps to call the YouTube Comment Search API: create a key, build the GET request, and process the returned comments.

01

Create An API Key

Create an AgentBody account and generate an API key in the console. Keep the key in your server environment or an approved secret store and send it as a bearer token — never in browser code or client bundles.

02

Build The GET Request

Send GET /v1/youtube/comments with the required url query parameter and an optional max_results from 1 to 50. The generated examples show the exact request in curl, JavaScript, Python, Java, and Go.

03

Keep The Key Server-Side

Call the endpoint from your backend, a serverless function, or a scheduled job. If end users trigger fetches, proxy through your own endpoint so the key and billing stay under your control.

04

Parse The JSON Response

Read the items array with id, author, text, like_count, and reply_count per comment, plus video_id and total. Run your keyword search, sentiment pass, or moderation filter over the texts directly.

05

Store What You Need

Persist the fields your product uses and tag each row with the video_id and fetch time. Comment sections change — store the snapshot your analysis was built on.

06

Handle Errors Correctly

Fix 400 responses by correcting the request, 401 by configuring a valid key. Retry 502, 503, and 504 with backoff — they are temporary upstream conditions, not permanent failures.

Frequently asked questions

What is the YouTube Comment Search API?

An authenticated GET endpoint, /v1/youtube/comments, that returns the public comment section of a YouTube video as structured JSON — items with id, author, text, like_count, and reply_count, plus video_id and total — for one video URL per call.

How does comment API pricing work?

Each fetch runs on your account's credits. Usage-based pricing is governed by the gateway rather than fixed numbers on this page — check the console for current per-call costs.

How is this different from the YouTube Data API?

No OAuth consent flow, no quota project, and no API-key-per-channel setup — one bearer key, one URL parameter, and a normalized comment shape. You trade Google's full comment-tree features for a single call that works on any public video.

Can I search the returned comments by keyword or author?

Yes — the response is structured JSON, so run any keyword, phrase, or author-name filter over the items array in your code. The API returns the section; the search logic is yours, which keeps matching as flexible as your product needs.

Does it return replies as well as top-level comments?

The endpoint returns top-level comments, each with a reply_count field showing how many replies it has. Reply text is not included in the current response shape — treat reply_count as the engagement signal.

How do I handle API errors?

Correct the request on 400, fix your bearer key on 401, and treat 502, 503, and 504 as temporary upstream failures to retry with backoff. Log status codes so your pipeline distinguishes bad requests from transient issues.