ScrapeMole
Home / Catalog / YouTube comments

YouTube comments API

Use when you need what viewers say about a YouTube video, e.g. sentiment, feedback mining, FAQ or product research: up to 100 top-level comments with text, like count, reply count, relative publish time and pinned / by-creator flags, plus the total comment count. Commenter names, handles and channel IDs are intentionally NOT returned. $0.005 per successful call; videos with comments off and errors are not charged.

Call it →openapi.jsonLive on Base$0.005 USDC per successful call

Parameters

GET https://scrapemole-api-mainnet.scrapemole.workers.dev/v1/youtube/comments

NameRequiredDescription
videoyesYouTube video URL or 11-character video ID.
sortnoComment order.
One of: top newest
Default: top
limitnoMax comments (1-100).
Default: 20
langnoInterface language (hl), e.g. en, de.
countrynoCountry (gl), e.g. US, GB.

Call it

// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPaymentFromConfig, decodePaymentResponseHeader } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm';
import { privateKeyToAccount } from 'viem/accounts';

// Your agent's own wallet, holding a little USDC on Base. No ScrapeMole account or API key.
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: 'eip155:8453', client: new ExactEvmScheme(account) }],
});

// On 402 the wrapper signs the USDC authorization and retries once.
const res = await pay('https://scrapemole-api-mainnet.scrapemole.workers.dev/v1/youtube/comments?video=aircAruvnKk&limit=20');
console.log(res.status, await res.json());
// Settled only on 200; the receipt (tx hash) is in the PAYMENT-RESPONSE header.
if (res.ok) console.log(decodePaymentResponseHeader(res.headers.get('payment-response')));

Also available as the MCP tool youtube_comments on https://scrapemole-api-mainnet.scrapemole.workers.dev/mcp (x402 MCP transport, same price).

Example response

A real response from this endpoint (arrays and long strings trimmed here).

{
  "videoId": "aircAruvnKk",
  "title": "But what is a neural network? | Deep learning chapter 1",
  "sort": "top",
  "totalComments": 9000,
  "count": 1,
  "comments": [
    {
      "commentId": "Ugx…",
      "text": "This is the clearest explanation of backprop I have seen.",
      "publishedText": "3 years ago",
      "likeCount": 1200,
      "replyCount": 14,
      "isByVideoCreator": false,
      "isPinned": false
    }
  ]
}

Live test results

2/2Paid calls through the deployed Worker, 12 Oct 2026 08:12 UTC

Paid end-to-end checks (Base Sepolia testnet, 12 Oct 2026 08:12 UTC)

CallStatusChargedPass
unpaid /v1/youtube/comments402price quoted✓
paid /v1/youtube/comments?video=aircAruvnKk&limit=30200$0.005✓
paid /v1/youtube/comments?video=aircAruvnKk&sort=newest&limit=5200$0.005✓
paid /v1/youtube/comments?video=nope (bad video ref)400$0✓

Errors

Failures return JSON like {"error": {"code": "NOT_FOUND", "message": "…", "charged": false}}. None of them are charged.

Status / errorCodeMeaning
400 INVALID_INPUTMissing or malformed parameter. Fix the input.
404 NOT_FOUNDThe video, channel, product or term doesn't exist or isn't public.
404 NO_DATAIt exists, but has nothing to return (for example no captions).
503 BLOCKEDThe source rate-limited us even after retries. Try again later.
502 / 504Upstream error or timeout. Try again.
402No or invalid payment. Pay the quoted amount and retry.