Use YouTube Trending Feed Extractor by Category & Market with Python
Get video lists for YouTube's Gaming, Music, News, Movies and Trending sections in any of 31 regional markets, with views, duration and channel details; rows from a fallback search are labeled.
1. Choose the data you need
Review the published README for supported collection modes, examples, and limits. The recipe below uses the current published input definition.
2. Prepare a source-based input
This JSON contains published prefills and required-field defaults. Review every value for your task before running it; it is not a promise of successful collection.
{
"categories": [
"gaming"
],
"charts": [
"trendingVideos"
],
"countries": [
"US"
],
"date": "",
"includeVideoDetails": false,
"maxConcurrency": 3,
"maxItems": 3,
"maxItemsPerChart": 3,
"mode": "charts",
"monitorName": "default",
"newsSections": [
"top"
],
"onlyNew": false,
"period": "daily"
}
Download input.example.json and save your reviewed copy as input.json.
| Field | Type | Required | Description |
|---|---|---|---|
mode | string | required | What to read. 'charts' uses YouTube's official music, trailer and podcast charts. 'hubs' uses YouTube's category pages such as Gaming trending, News, Sports, Learning and Courses. |
charts | array | optional | One or more YouTube charts. Trending music videos is the official replacement for the retired general Trending page. Top songs and top artists are weekly; Shorts songs is daily or weekly. Music and Shorts charts include rank movement and optional history. |
categories | array | optional | One or more category pages. Gaming trending and Gaming live return up to 50 videos. News reads the selected news sections. Sports, Learning and Courses are editorial category feeds. |
newsSections | array | optional | Which News tabs to read. 'Top stories' is the main /news page; the other sections are direct news-destination feeds. Available sections vary by country. |
countries | array | optional | One or more markets. The 68 YouTube Charts markets are supported; 'global' is supported only for charts that publish a global ranking (top videos, top songs, top artists, Shorts songs). |
period | string | optional | Daily or weekly ranking. Weekly-only charts automatically use weekly. Current-only charts such as Trending music videos and Trending movie trailers ignore this setting. |
date | string | optional | Historical chart date in YYYY-MM-DD format. Leave empty for the latest chart. Supported by Top music videos, Top songs, Top artists and Shorts songs; current-only charts ignore it. |
maxItems | integer | optional | Total data rows to return across all charts, categories and countries. |
maxItemsPerChart | integer | optional | Rows to take from each chart/country or category/country combination. Source ceilings still apply. |
includeVideoDetails | boolean | optional | Fetch exact lifetime views, likes, upload dates and descriptions for every video. YouTube category, tags, Shorts eligibility and family-safe flags are filled when YouTube's player response is available and may be omitted on some cloud IPs. Adds one or more detail requests per video. |
maxConcurrency | integer | optional | How many exact-detail requests may run in parallel. |
onlyNew | boolean | optional | Skip rows already emitted by a previous run with the same monitor name. |
monitorName | string | optional | Separate only-new histories by monitor name. |
3. Start an Actor run
Set APIFY_TOKEN in your environment. Python 3.10 or newer is sufficient; this recipe uses no third-party packages.
Execution may incur charges. Review current pricing on Apify. The request asks for a 120-second timeout and a charge limit; these settings are subject to Apify’s pricing and do not guarantee an all-inclusive spending cap.
import json
import os
import urllib.request
# Save the schema-derived example as input.json; review and edit it first.
with open("input.json", encoding="utf-8") as stream:
actor_input = json.load(stream)
token = os.environ["APIFY_TOKEN"]
request = urllib.request.Request(
"https://api.apify.com/v2/acts/GnLvTq8m3i6444nUe/runs?timeout=120&maxTotalChargeUsd=0.50",
data=json.dumps(actor_input).encode("utf-8"),
headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
method="POST",
)
# This starts a potentially billable run. Do not automatically retry this POST.
with urllib.request.urlopen(request, timeout=40) as response:
run = json.load(response)["data"]
print("Run ID:", run["id"])
print("Status:", run["status"])
# Inspect and download results in Apify Console once the run succeeds.
4. Inspect the actual results
Open the run in Apify Console and wait for a successful completion. Use the published output schema to locate results and the dataset schema to understand declared views. Missing or optional record fields must not be treated as guaranteed values.
Ranked YouTube chart entries and category-hub videos with rank movement, exact video details and status rows.
Questions before you run
Which inputs are required?
The published required fields are mode
What does this guide verify?
The fields, prefills, and schema links are rendered from the published build. This is a usage recipe, not a paid live extraction test. Source availability and collection results can vary.
What if the run request times out?
Check Apify Console before retrying. The first request may already have created a run. Do not automatically repeat a run-creation POST.
Generated from source build edchdAkSbD3iMNJ6D and its README and schemas. Source changes regenerate this guide; no third-party editorial claims are inferred.