ScrapeMole Apify Store
Home / x402 API / YouTube search

YouTube search API

Use when you need to find YouTube videos for a query, e.g. competitor or trend research.

Live on Base$0.002 USDC per successful call· MCP tool youtube_search

Parameters

Use when you need to find YouTube videos for a query, e.g. competitor or trend research. Returns up to 50 videos per call with title, channel, views, duration, approximate publish date and thumbnail; optional filters for sort order, upload date and duration. Flat price for any number of videos up to the limit; errors are not charged.

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

NameRequiredDescription
qyesSearch query.
limitnoMax videos (1-50).
Default: 20
sortnoSort order.
One of: relevance date views rating
Default: relevance
uploadednoUpload date filter.
One of: any hour today week month year
Default: any
durationnoDuration filter.
One of: any short medium long
Default: any
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 or Solana. 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/search?q=espresso%20machine%20review&limit=10');
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')));

No crypto wallet? The same data comes from our Apify Actor YouTube Scraper: batch runs, pay per result with an Apify account, export CSV/JSON, or connect n8n, Make and Zapier.

Run on Apify ↗

Also available as the MCP tool youtube_search 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).

{
  "count": 2,
  "videos": [
    {
      "videoId": "4MJnPVnY3_o",
      "url": "https://www.youtube.com/watch?v=4MJnPVnY3_o",
      "title": "The Best Espresso Machine You've Never Heard Of",
      "channelName": "Daddy Got Coffee",
      "channelId": "UCu7x43fFlwbBykF1r04T_wQ",
      "channelHandle": "@DaddyGotCoffee",
      "channelUrl": "https://www.youtube.com/channel/UCu7x43fFlwbBykF1r04T_wQ",
      "viewCount": 158741,
      "viewCountText": "158,741 views",
      "publishedText": "8 months ago",
      "publishedAtApprox": "2026-02-07",
      "durationSeconds": 1215,
      "durationText": "20:15",
      "isShort": false,
      "isLive": false,
      "badges": [
        "4K"
      ],
      "isVerifiedChannel": false,
      "descriptionSnippet": "The $3000 espresso category hasn't changed in years — until now. The Arkel Coast brings saturated group performance, flow ...",
      "thumbnailUrl": "https://i.ytimg.com/vi/4MJnPVnY3_o/maxresdefault.jpg",
      "sourceType": "search",
      "searchQuery": "espresso machine review",
      "position": 2,
      "likeCount": 1986,
      "commentCount": 280,
      "publishDate": "2026-02-07T03:00:13-08:00",
      "uploadDate": "2026-02-07T03:00:13-08:00",
      "category": "People & Blogs",
      "description": "The $3,000 espresso category hasn’t changed in years — until now.\nThe Arkel Coast brings saturated group performance, flow control, shot …",
      "keywords": [],
      "isLiveNow": false,
      "isFamilySafe": true,
      "isShortsEligible": false,
      "availableCountriesCount": 249
    },
    {
      "videoId": "miNqgmVH9I0",
      "url": "https://www.youtube.com/watch?v=miNqgmVH9I0",
      "title": "Best Entry Level Espresso Machines 2025 – Our Top Picks for Beginners",
      "channelName": "Whole Latte Love",
      "channelId": "UCJwRmBtnYh_7Xs9oXUrLhZg",
      "channelHandle": "@Wholelattelovepage",
      "channelUrl": "https://www.youtube.com/channel/UCJwRmBtnYh_7Xs9oXUrLhZg",
      "viewCount": 169694,
      "viewCountText": "169,716 views",
      "publishedText": "11 months ago",
      "publishedAtApprox": "2025-11-08",
      "durationSeconds": 929,
      "durationText": "15:30",
      "isShort": false,
      "isLive": false,
      "badges": [
        "4K"
      ],
      "isVerifiedChannel": true,
      "descriptionSnippet": "Looking for the best entry level espresso machine in 2025? We tested the top affordable espresso machines to find which ones ...",
      "thumbnailUrl": "https://i.ytimg.com/vi_webp/miNqgmVH9I0/maxresdefault.webp",
      "sourceType": "search",
      "searchQuery": "espresso machine review",
      "position": 3,
      "likeCount": 1259,
      "commentCount": 115,
      "publishDate": "2025-11-07T12:30:07-08:00",
      "uploadDate": "2025-11-07T12:30:07-08:00",
      "category": "Howto & Style",
      "description": "Looking for the best entry level espresso machine in 2025? We tested the top affordable espresso machines to find which ones make real ca…",
      "keywords": [
        "best entry level espresso machine 2025",
        "espresso machine for beginners"
      ],
      "isLiveNow": false,
      "isFamilySafe": true,
      "isShortsEligible": false,
      "availableCountriesCount": 249
    }
  ]
}

Errors

Failed calls and bad inputs are never charged. Every failure returns JSON like {"error": {"code": "NOT_FOUND", "message": "…", "charged": false}}, so an agent knows whether to fix the input or retry.

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.