A trend on YouTube is a change in what creators talk about: a product that goes from rare to everywhere in a month, a topic that flips from praise to complaints, a new name that suddenly appears in every review. View counts show that something is popular. What is said in the videos shows what it is and which way opinion is moving.
This post builds that pipeline end to end. First the YouTube Data API collects a niche’s recent videos with a handful of quota units. Then TubeExtract turns what is said in them into typed rows. Last, a short script turns the rows into a weekly trend table. The example follows electric bike reviews, and the same three scripts work for any niche: swap the channels and the two columns.
The pipeline in three steps
- Collect. List the channels in your niche, fetch their uploads from the last few months with the YouTube Data API, and keep each video’s id, title, publish date, length and views.
- Extract. Send the video URLs to TubeExtract with a schema: the columns you want per video, such as the product reviewed and the host’s sentiment.
- Analyze. Join the rows back to the publish dates, group by week and compare the recent weeks with the ones before.
You need two keys: a YouTube Data API key from the Google Cloud console and a TubeExtract key from your dashboard. The scripts below are Node 20 or later and read them from YOUTUBE_API_KEY and TUBEEXTRACT_KEY.
Step 1: get the videos with the YouTube Data API
The obvious endpoint is search.list, and it is the expensive one. Google publishes the quota cost of each method: a search call is 100 units, while playlistItems.list, channels.list and videos.list are 1 unit each. A new project gets 10,000 units a day.
| Call | Units | What it gives you |
|---|---|---|
| channels.list | 1 | A channel’s uploads playlist, from its handle |
| playlistItems.list | 1 per page of 50 | Every upload, newest first, with its publish date |
| videos.list | 1 per 50 videos | Title, length and view count |
| search.list | 100 | Ranked search results; not needed here |
So the plan is to walk each channel’s uploads playlist. Because it is ordered newest first, the script stops paging the moment it reaches a video older than the cut-off. Twenty channels with a few dozen uploads each in the window come to well under a hundred units.
videos.json costs nothing, while re-fetching spends quota every time.Choosing the channels
The channel list is the sample, so it decides what the trend means. Pick channels that cover your niche the way a reader of the result would expect: the big names and a spread of mid-sized ones. Fifteen to thirty channels over ninety days gives a few hundred videos, enough for week-by-week shares to be stable.
Step 2: feed the videos into TubeExtract
TubeExtract reads what is said in each video and returns one row per thing you asked for, typed and validated against your schema. For a trend you want few, well-worded columns. Here a row is one product a host reviews, with the host’s overall opinion of it:
productas averbatim-string, so names come back as the host says them and can be matched across videos.sentimentas anenumwith three options, so every value is one you can count.multiple: true, because a comparison video covers several products.
The script sends up to 200 URLs per request, polls the job until it settles and writes the rows to disk in the same step. Results are returned once, so persisting where you read is the safe pattern (see the get-job reference). On a paid plan a webhook_url can replace the polling loop.
What a run costs
Credits are 10 per started minute of video, charged before extraction. A 12-minute video is 120 credits, so a run of 300 videos averaging 12 minutes is 36,000 credits. The levers are the ones already in the first script: a minimum length that drops Shorts, a tighter channel list and a shorter window. A video with no caption track returns no_captions and is never charged. See credits and limits for the plans.
Wording the columns
The description is the instruction the model follows. “An electric bike model the host reviews or compares” returns the bikes the video is about; a looser “a bike” also returns every bike mentioned in passing. If you want to try wording changes cheaply, run them on five or ten videos first. The writing a schema guide covers it in more detail.
Step 3: turn rows into a trend
Every row belongs to a video, and every video has a publish date from step 1. That join is the whole trick. The script groups mentions by the Monday of the week the video was published, counts each product once per video, and compares the last four weeks with the four before.
The output is a ranking of what is rising, in this shape (illustrative values):
Reading it well
- Use shares, not counts. Channels upload more in some weeks. The share of that week’s videos mentioning a product stays comparable; a raw count does not.
- Merge names. Hosts say “the model a”, “model a pro” and “model A”. Lower-casing handles the last; a small alias map handles the rest, built from the product values in
rows.json. - Add sentiment. The script already tracks the positive count. A product that is rising and mostly positive is a different story from one that is rising because it is being complained about.
- Weight by views when it matters. The
viewsfield invideos.jsonlets you count a mention in a million-view video for more than one in a small channel’s. - Keep the window rolling. Run step 1 weekly with a seven-day cut-off, extract only the new videos and append. The history builds itself, and each run costs a handful of units and credits.
From here the rows go wherever your analysis lives: a spreadsheet, a notebook, a warehouse table or a dashboard. The same pattern works for a topic instead of a product (use a column such as topic_discussed), for creators sponsoring a brand, for questions viewers keep asking, or for any list of channels you want to watch.
Ready to run it on your niche? The quickstart gets your first job back in a few minutes, and the starter credits that come with a free account (no card) let you try the three scripts on a small channel list.
Frequently asked questions
How do I get a list of videos from a YouTube channel with the API?
Call channels.list with the channel's handle to get its uploads playlist, then page through playlistItems.list. Each call costs 1 quota unit and returns up to 50 videos, newest first, so a channel's last three months is usually one or two calls.
Why not use YouTube search to find videos?
search.list costs 100 quota units a call against 1 for playlistItems.list, and the default quota is 10,000 units a day. Walking channel upload playlists covers the same ground for a hundredth of the price, and gives you every upload rather than a ranked sample.
How many videos can I send to TubeExtract at once?
Up to 200 video URLs in one request. Larger lists are split into several requests, each with its own job id.
What does analyzing a video cost?
10 credits per started minute of video, charged before extraction. A video without a caption track returns no_captions and is never charged, so filtering out very short videos and videos you do not need keeps a run small.