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 search data from YouTube
Learn how to scrape YouTube search results using JavaScript. 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 JavaScript. Replace YOUR_API_KEY
with your actual API key.
This endpoint accepts the following parameters:
query
Required(string)Search query
uploadDate
Optional(select)Upload date
sortBy
Optional(select)Sort by
Example: relevance
filter
Optional(select)Filter by these options. Note this doesn't work when you use either 'uploadDate' or 'sortBy'. It basically only works when you have a query.
Example: all
continuationToken
Optional(string)Continuation token to get more videos. Get 'continuationToken' from previous response.
Example: 4qmFsgKrCBIYVUNkRkpXVWE0M3NtUm00SXBIQnB
includeExtras
Optional(string)This will get you the like + comment count and the description. To get the full details of the video, use the /v1/youtube/video endpoint. *This will slow down the response slightly.*
Example: false
Execute your script to test the API connection. You should see a JSON response with YouTube search results data.
✅ Success: You should receive a structured JSON response containing the requested data.
Here's an example of the JSON response you'll receive:
Check that your response includes the expected fields:
videos
(object)channels
(object)playlists
(object)shorts
(object)shelves
(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 search results, consider batching requests to maximize throughput while staying within rate limits.
Use asynchronous processing in JavaScript to handle multiple requests concurrently and improve overall performance.
Analyze YouTube search results to understand market trends, competitor analysis, and audience insights.
Track performance metrics, engagement rates, and content trends across YouTube search results.
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 JavaScript HTTP concepts that work with any framework. The API calls remain the same regardless of your specific JavaScript 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.