YouTube search API
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. $0.01 per successful call (any number of videos up to the limit); errors are not charged.
Parameters
GET https://scrapemole-api-mainnet.scrapemole.workers.dev/v1/youtube/search
| Name | Required | Description |
|---|---|---|
q | yes | Search query. |
limit | no | Max videos (1-50). Default: 20 |
sort | no | Sort order. One of: relevance date views ratingDefault: relevance |
uploaded | no | Upload date filter. One of: any hour today week month yearDefault: any |
duration | no | Duration filter. One of: any short medium longDefault: any |
lang | no | Interface language (hl), e.g. en, de. |
country | no | Country (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/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')));
# 1. Unpaid: returns 402 with price $0.01 and the payTo address curl -i "https://scrapemole-api-mainnet.scrapemole.workers.dev/v1/youtube/search?q=espresso%20machine%20review&limit=10" # 2. Paid: repeat the request with a PAYMENT-SIGNATURE header (a signed USDC # authorization for the quoted amount). An x402 client does this for you: # see the JavaScript tab.
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
}
]
}Live test results
Paid end-to-end checks (Base Sepolia testnet, 11 Oct 2026 18:36 UTC)
| Call | Status | Charged | Pass |
|---|---|---|---|
unpaid /v1/youtube/search | 402 | price quoted | ✓ |
paid /v1/youtube/search?q=espresso%20machine%20review&limit=10 | 200 | $0.01 | ✓ |
paid /v1/youtube/search?limit=5 (missing q) | 400 | $0 | ✓ |
Errors
Failures return JSON like {"error": {"code": "NOT_FOUND", "message": "…", "charged": false}}. None of them are charged.
| Status / errorCode | Meaning |
|---|---|
400 INVALID_INPUT | Missing or malformed parameter. Fix the input. |
404 NOT_FOUND | The video, channel, product or term doesn't exist or isn't public. |
404 NO_DATA | It exists, but has nothing to return (for example no captions). |
503 BLOCKED | The source rate-limited us even after retries. Try again later. |
502 / 504 | Upstream error or timeout. Try again. |
402 | No or invalid payment. Pay the quoted amount and retry. |