How to export YouTube search results (and trending videos) with view counts
Short answer
Use the official YouTube Data API: search.list returns the ranked video IDs for a keyword and videos.list adds views, likes, comments and duration. Vidtrawl on Apify runs both with your own free API key for any list of keywords, with date, length, country and language filters, at $0.20 per 1,000 videos plus $0.001 per run.
- Create a free YouTube Data API key: Google Cloud Console, new project, enable YouTube Data API v3, Credentials, Create API key (about 3 minutes, no billing account).
- Open Vidtrawl on Apify and paste the key into the YouTube Data API key field.
- Add search terms, one per line, and choose Results per search (up to about 500).
- Optional: sort by date or views, set a published-after date, a length, a country or a minimum view count.
- Optional: add country codes under Trending to get the most-popular chart.
- Run and download CSV or Excel. For alerts, turn on Monitor mode, sort by upload date and schedule it daily.
Copy-paste code
Python (pip install apify-client)
import os
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("cybermax/youtube-search-scraper").call(run_input={"apiKey": os.environ["YOUTUBE_API_KEY"], "queries": ["web scraping tutorial"], "maxResultsPerQuery": 50})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
print(row)cURL (one call, rows come back as JSON)
curl -X POST "https://api.apify.com/v2/acts/cybermax~youtube-search-scraper/run-sync-get-dataset-items" \
-H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
-d '{"apiKey": "YOUR_YOUTUBE_API_KEY", "queries": ["web scraping tutorial"], "maxResultsPerQuery": 50}'No code: n8n, Make or Zapier
n8n: HTTP Request node (or the Apify node, action "Run an Actor and get dataset")
Method: POST
URL: https://api.apify.com/v2/acts/cybermax~youtube-search-scraper/run-sync-get-dataset-items
Auth: Header Auth -> Authorization: Bearer <your Apify token>
Body: JSON {"apiKey": "YOUR_YOUTUBE_API_KEY", "queries": ["web scraping tutorial"], "maxResultsPerQuery": 50}
Make: Apify app -> "Run an Actor" (Actor: cybermax/youtube-search-scraper, wait for finish = yes) -> "Get Dataset Items"
Zapier: Apify app -> action "Run Actor" (cybermax/youtube-search-scraper) -> "Fetch Dataset Items" -> your appFrom an AI agent (MCP)
# Any MCP client (Claude Desktop, Claude Code, Cursor, VS Code): Apify's hosted MCP server
{
"mcpServers": {
"youtube-search-scraper": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.apify.com/?tools=cybermax/youtube-search-scraper",
"--header", "Authorization: Bearer ${APIFY_TOKEN}"],
"env": { "APIFY_TOKEN": "<your Apify token>" }
}
}
}
# The agent sees one tool, cybermax--youtube-search-scraper, with the Actor's input schema (pass your YouTube API key in apiKey).| search | # | title | channel | length | views | likes |
|---|---|---|---|---|---|---|
| web scraping tutorial | 1 | Learn Web Scraping in 5 Minutes (NO PRIOR KNOWLEDGE) | CodeHead | 4:53 | 188,610 | 6,852 |
| web scraping tutorial | 3 | Python Web Scraping Tutorial: Complete Guide 2026 | Oxylabs | 8:01 | 9,442 | 555 |
| trending:US | 50 | The Elite: Army Rangers | Official Trailer | Paramount+ | Paramount Plus | 1:31 | 46,317 | 523 |
Source: Vidtrawl (Apify Actor cybermax/youtube-search-scraper) README, real Apify run on 12 Nov 2026
Why you need your own API key
YouTube's terms and its robots.txt do not allow scraping its pages, so the legitimate way to read video data in bulk is the official YouTube Data API. Google gives each project 10,000 free units a day and ties them to a key, which is why the key is yours and not ours.
The key is a secret input: it is stored encrypted on Apify, sent only to googleapis.com and never written to logs or results. You can restrict it to the YouTube Data API and revoke it at any time.
The quota to plan around
A search page of 50 results costs 100 API units, so the free 10,000 daily units cover about 100 pages, or 5,000 results a day. Trending charts cost 1 unit per 50 videos. If you need more, request a higher quota in Google Cloud Console or spread schedules over the day.
Search is fuzzy
YouTube's search returns loosely related videos when there are few exact matches. Put exact phrases in quotes and use a minimum view count to drop noise. Results can also differ a little from what a signed-in person sees on youtube.com.
Good to know
YouTube returns at most about 500 results per search.
The API has no Shorts-only switch; use the under-4-minutes length filter.
Gripeline: See what users hate about any app
$0.0001 per review + $0.003 per app summaryTracking what people say about an app as well? Gripeline pulls App Store and Google Play reviews into the same kind of table.
Runs on your own Apify account, pay per result; failed results are not charged.Questions
Is it free to try?
Run it with no key for a free demo of the output format. With a key, Apify's free plan includes $5 of monthly credit, enough for about 24,000 results, and Google's quota is free.
Can I get an alert for new videos about my brand?
Yes. Monitor mode with Sort by: Upload date returns only videos not delivered before; schedule it daily and connect Slack or email in Apify Integrations.
Does it return transcripts or comments?
No. It returns the comment count and whether captions exist.
Can an AI agent use it?
Yes. Apify's MCP server exposes it as cybermax--youtube-search-scraper.
Free: the Free API Starter Kit
Copy-paste calls for 4 APIs with free daily tiers (CVE priority, VIN recalls, US duty rates, email checks), then 5 short emails on KEV/EPSS, MCP and free data.