What You'll Learn
- • Setting up your development environment
- • Installing the required HTTP client
- • Authenticating with the ScrapeCreators API
- • Making requests to YouTube
- • Handling responses and errors
- • Best practices for production use
Extract trending data from YouTube
Learn how to scrape YouTube trendings using Node.js. This comprehensive guide will walk you through the entire process, from setup to implementation.
First, you'll need a ScrapeCreators API key to authenticate your requests.
Sign up at app.scrapecreators.com to get your free API key with 100 requests.
Make sure you have the following installed:
Axios is a promise-based HTTP client for Node.js
npm install axios
Now let's make a request to the YouTube API using Node.js. Replace YOUR_API_KEY
with your actual API key.
import axios from 'axios';
const API_KEY = 'YOUR_API_KEY';
async function scrape() {
try {
const response = await axios.get(`https://api.scrapecreators.com/v1/youtube/shorts/trending?`, {
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
}
});
console.log('Response:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
// Usage
scrape();
This endpoint accepts the following parameters:
Execute your script to test the API connection. You should see a JSON response with YouTube trendings data.
✅ Success: You should receive a structured JSON response containing the requested data.
Here's an example of the JSON response you'll receive:
{
"success": true,
"shorts": [
{
"id": "ou0nl5ET0HA",
"thumbnail": "https://img.youtube.com/vi/ou0nl5ET0HA/maxresdefault.jpg",
"url": "https://www.youtube.com/watch?v=ou0nl5ET0HA",
"title": "That hooper who says their just shoes",
"description": null,
"commentCountText": "168",
"commentCountInt": 168,
"likeCountText": "151957",
"likeCountInt": 151957,
"viewCountText": "13,798,774",
"viewCountInt": 13798774,
"publishDateText": "Aug 7, 2025",
"publishDate": "2025-08-07T13:00:22-07:00",
"channel": {
"id": "UC3iObCgKLKr9xquQw7fCang",
"url": "https://www.youtube.com/@dameuniverse",
"handle": "dameuniverse",
"title": "Dame Universe"
},
"chapters": [],
"keywords": [
"Kobe",
"Sneaker heads",
"Kobe Bryant",
"House of highlights",
"Funny memes",
"Epic basketball",
"High school hoops",
"Relatable memes",
"Basketball entertainment",
"Basketball shoes"
],
"durationMs": 19000,
"durationFormatted": "00:00:19"
},
{
"id": "RHjn1eyPLgI",
"thumbnail": "https://img.youtube.com/vi/RHjn1eyPLgI/maxresdefault.jpg",
"url": "https://www.youtube.com/watch?v=RHjn1eyPLgI",
"title": "Save of the Century 🫡 Real Hero 💪 #discipline#success #mindset#ego#shorts#fyp#edit#motivation",
"description": "Save of the Century 🫡 Real Hero 💪 #discipline#success #mindset#ego#shorts#fyp#edit#motivation\n\nWork Smart 🧠#discipline#success #mindset#ego#shorts#fyp#edit#mentality#motivation\n\nThey won't appreciate you until you leave. Keep carrying them, and they'll think it's easy. Stop - and watch their world fall apart. Stay dangerous. Stay valuable.\nStay irreplaceable.\n\n#motivation #mindset #knowyourworth #staydangerous #selfrespect #discipline #successmindset #alphaenergy #viralshorts #motivationalshorts #valueyourself\n\nEgo is the part of us that shapes our self-identity and confidence, but it can also lead to pride or defensiveness.\nThis simple look at ego explores what it is, how it affects our thoughts and actions, and why balancing it matters in daily life.\nA quick guide to understanding yourself-and others-better.\n\nRelated:-Space, Universe, Space Edit, Astronomy, Cosmos,\nThose who know,\nScience, Ocean,\n#space #universe\nTags:\n#space #universe #stars #galaxy #blackhole #nasa #trendingshorts #solarsystem #nature #ocean #cosmos #science #planets #earth #moon #mars #jupiter #saturn #venus #mercury #uranus #neptune #pluto #astronomy #astrophysics #spacex #satellite #milkyway #comet #rocket #orbit #spacecraft #shorts #fyp #youtube #viralvideo #trending #reels #shortsvideo #viralshorts #astronomyfacts #spacescience #telescope #gravity #meteors #asteroid #nebula #supernova #exoplanet #bigbang #cosmology #spaceexploration #eclipse #hubble #jameswebb #aliens #extraterrestrial #life #multiverse #iss #facts #youtubeshort #knowledge #sciencefacts #trend #viralshort #spacefacts #sun #astronomy #scienceeducation #trendingshorts",
"commentCountText": "1.5K",
"commentCountInt": 1500,
"likeCountInt": null,
"viewCountText": "9,550,557",
"viewCountInt": 9550557,
"publishDateText": "Jul 18, 2025",
"publishDate": "2025-07-18T09:42:58-07:00",
"channel": {
"id": "UCj7yUpOuWpLhiiPjf2w15zg",
"url": "https://www.youtube.com/@MYVISIONshorts",
"handle": "MYVISIONshorts",
"title": "MY VISION"
},
"chapters": [],
"keywords": [
"motivation",
"know your worth",
"mindset shift",
"stay dangerous",
"alpha male energy",
"success mindset",
"viral shorts",
"motivational shorts",
"never settle",
"grind mindset",
"never give up",
"ego boost",
"viral motivation video",
"life lessons",
"viral tiktok",
"shorts feed inspiration",
"discipline over motivation",
"stay valuable",
"self worth motivation",
"emotional motivation",
"power",
"value yourself",
"dangerous",
"Kids",
"Near death experience",
"Adrenaline",
"Discipline",
"Avengers",
"Bike accident",
"Help",
"Hero",
"Superhero"
],
"durationMs": 8000,
"durationFormatted": "00:00:08"
},
{
"id": "urisfWQu5bc",
"thumbnail": "https://img.youtube.com/vi/urisfWQu5bc/maxresdefault.jpg",
"url": "https://www.youtube.com/watch?v=urisfWQu5bc",
"title": "The Laser Grab Illusion Explained",
"description": null,
"commentCountText": "48",
"commentCountInt": 48,
"likeCountText": "65072",
"likeCountInt": 65072,
"viewCountText": "1,719,730",
"viewCountInt": 1719730,
"publishDateText": "Jul 25, 2025",
"publishDate": "2025-07-25T17:29:48-07:00",
"channel": {
"id": "UCoGcvX8WSTOpK52Y81OfVFg",
"url": "https://www.youtube.com/@FactasticFeed",
"handle": "FactasticFeed",
"title": "FactasticFeed"
},
"chapters": [],
"keywords": [
"shorts",
"short"
],
"durationMs": 20000,
"durationFormatted": "00:00:20"
}
]
}
Check that your response includes the expected fields:
success
(boolean)shorts
(object)Implement comprehensive error handling and retry logic for failed requests. Log errors properly for debugging.
Cache responses when possible to reduce API calls and improve performance. Consider data freshness requirements.
Never expose your API key in client-side code. Use environment variables and secure key management practices.
When scraping multiple trendings, consider batching requests to maximize throughput while staying within rate limits.
Use asynchronous processing in Node.js to handle multiple requests concurrently and improve overall performance.
Analyze YouTube trendings to understand market trends, competitor analysis, and audience insights.
Track performance metrics, engagement rates, and content trends across YouTube trendings.
Identify potential customers and business opportunities throughYouTube data analysis.
Check your API key is correct and properly formatted in the x-api-key header.
You ran out of credits and need to buy more.
The resource might not exist or be private.
Temporary server issue. Implement retry logic with exponential backoff.
ScrapeCreators offers 100 free API calls to get started. After that, pricing starts at $10 for 5k requests with volume discounts available.
Scraping publicly available data is fair game, and we only collect public data. So anything that you can see in an incognito browser is what we collect.
There is no rate limit! So you can scrape as fast as you want!
All API responses are returned in JSON format, making it easy to integrate with any programming language or application.
Yes! This tutorial focuses on core Node.js HTTP concepts that work with any framework. The API calls remain the same regardless of your specific Node.js setup.
For large datasets, implement pagination, use streaming responses where available, and consider storing data in a database for efficient querying.
Get started with 100 free API calls. No credit card required.