Disclosure: I made the Actor used in this article, so I'm biased. Apify links here are referral links. The official YouTube Data API is still the right choice if you have a key and the quota; I note that path below.
The official YouTube Data API is solid, but it needs a Google Cloud project, an API key, and a daily quota. On the default cap that is 100 search calls a day, plus 10,000 units a day for other read methods. Once you hit those caps, the official client just stops.
Here is how to get video stats (title, views, likes, comment count, subscribers, tags, duration, publish date) and, if you want them, the comments, from a search, a channel, a playlist or a list of links — in Python, without that key.
What you'll need
- Python 3.9 or newer
- A free Apify account (new accounts include free monthly platform credit; please check the current credit on Apify's pricing page)
- Your Apify API token, from Settings → API & Integrations
pip install -U apify-client pandas export APIFY_TOKEN="your-token-here" Step 1: Run a small search
YouTube Data Scraper takes search queries, channel links, playlist links and video links, mixed in one input. Pricing is $0.002 per video delivered ($2 per 1,000) and $0.0015 per comment ($1.50 per 1,000) only when you switch comments on. Failed or missing videos are not charged.
import os import pandas as pd from apify_client import ApifyClient client = ApifyClient(os.environ["APIFY_TOKEN"]) run = client.actor("logicbase_systems/youtube-data-scraper").call(run_input={ "searchQueries": ["python tutorial"], "maxResults": 5, }) Five search results cost $0.01 plus a tiny start fee. This is the same first-run input as on the Store page. Searches of 15 videos took 9 and 11 seconds on our 16 November 2026 test runs.
Step 2: Read the video rows
rows = list(client.dataset(run.default_dataset_id).iterate_items()) videos = [r for r in rows if r.get("type") == "video"] errors = [r for r in rows if r.get("type") == "error"] print(f"{len(videos)} videos, {len(errors)} errors") for v in videos: print(f"{v['title']} views={v.get('viewCount')} likes={v.get('likeCount')} {v['url']}") Each video row has title, description, channel name, handle, subscribers, views, likes, comment count, duration, publish date, tags, category, thumbnail, and flags for Shorts and live streams. Some of those numbers are hidden by YouTube on a few videos (likes turned off, subscribers hidden, no comment count on a live stream). In our 16 November 2026 runs, across 855 different videos, title, channel, views, duration and publish date were filled on every row; description 98%, subscribers 99%, likes 99%, comment count 95%.
Larger runs the same day: 150 of 150 videos from six searches in 66 seconds, 180 of 180 from three channels, and 300 of 300 from a large channel.
Step 3: Save a CSV
cols = [ "title", "url", "channelName", "channelHandle", "channelSubscribers", "viewCount", "likeCount", "commentCount", "duration", "publishDate", "isShort", "isLive", "tags", ] df = pd.DataFrame(videos) keep = [c for c in cols if c in df.columns] df[keep].to_csv("youtube_videos.csv", index=False) Optional: include comments
Add two fields to the same input. Comments arrive as extra rows with type set to "comment", each pointing back at the video.
run = client.actor("logicbase_systems/youtube-data-scraper").call(run_input={ "searchQueries": ["python tutorial"], "maxResults": 3, "includeComments": True, "maxComments": 10, "commentSort": "top", }) rows = list(client.dataset(run.default_dataset_id).iterate_items()) videos = [r for r in rows if r.get("type") == "video"] comments = [r for r in rows if r.get("type") == "comment"] print(f"{len(videos)} videos, {len(comments)} comments") comment_cols = ["videoTitle", "videoUrl", "author", "text", "likeCount", "replyCount", "isPinned", "isHearted"] cdf = pd.DataFrame(comments) if not cdf.empty: keep_c = [c for c in comment_cols if c in cdf.columns] cdf[keep_c].to_csv("youtube_comments.csv", index=False) Three videos plus up to 10 top comments each is about $0.006 for the videos and up to $0.045 for the comments. A video with comments turned off returns no comment rows and is not charged for comments.
On 16 November 2026, 1,000 comments from one video came back in 29 seconds, all unique, with no failed comment pages. A batch of 100 top comments each for five videos also succeeded; the sixth video in that run had comments off and returned none.
Channels, playlists and filters
The same call accepts a mix of sources:
run_input = { "channelUrls": ["https://www.youtube.com/@3blue1brown"], "playlistUrls": ["https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi"], "videoUrls": ["https://www.youtube.com/watch?v=aircAruvnKk"], "maxResults": 10, "channelTab": "videos", # or "shorts", "streams" "channelSort": "newest", # or "popular" "searchSort": "date", # for searches: relevance, date, views, rating "uploadDate": "week", } A video found twice (for example in a search and in a playlist) is returned once.
Things to know before you rely on it
- This reads public YouTube pages. It does not bypass age gates, members-only videos or private videos. Those come back as a free error row.
- Subscriber counts, and some comment-like totals when comments are not fetched, are the rounded figures YouTube shows on the page. Exact view and like counts are included when YouTube exposes them; each rounded field has a matching
...Textand...IsExactflag. - Check that your use of the data respects YouTube's terms and the creators' rights, especially if you republish comments or descriptions.
The official-API alternative
If you have a Google Cloud project and the default quota is enough, use the YouTube Data API. A search.list call counts against a separate daily cap of 100 searches. videos.list and commentThreads.list each cost 1 unit from the 10,000-unit pool. That is the supported path, and it is the one you should use when you can.
yt-dlp can also list a channel or playlist and print metadata from your own computer (yt-dlp --flat-playlist --print "%(id)s %(title)s %(view_count)s" CHANNEL_URL). YouTube often rate-limits or blocks the same requests once they come from a cloud server.
Ready-made Task pages, if you would rather press Start than write code:
- YouTube search results
- Channel videos with stats
- Video comments
- Stats from a URL list
- Shorts scraper
If you also need the spoken text of the videos, there is a companion YouTube Transcript & Subtitles Scraper and a walkthrough: How to get transcripts from an entire YouTube playlist.
If something doesn't work for you, open an issue on the Actor page and I'll look at it.
