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
Tutorial · YouTube
☕ Java Step-by-stepExtract shorts data from YouTube. Real code, real responses, real production patterns — paste it into your project and ship.
Learn how to scrape YouTube shorts using Java. 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:
Apache HttpClient is a robust HTTP client for Java
mvn dependency:add -DgroupId=org.apache.httpcomponents -DartifactId=httpclient -Dversion=4.5.13Now let's make a request to the YouTube API using Java. Replace YOUR_API_KEY with your actual API key.
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.stream.Collectors;
public class Scraper {
private static final String API_KEY = "YOUR_API_KEY";
private static final String BASE_URL = "https://api.scrapecreators.com";
private static final String ENDPOINT_PATH = "/v1/youtube/channel/shorts";
public static void main(String[] args) {
try {
String result = scrape();
System.out.println("Response: " + result);
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
public static String scrape() throws Exception {
HttpClient client = HttpClient.newHttpClient();
// Build query parameters
Map<String, String> params = Map.of(
"handle", "starterstory",
"channelId", "UC-9-kyTW8ZkZNDHQJ6FgpwQ",
"sort", "newest",
"continuationToken", "4qmFsgKrCBIYVUNkRkpXVWE0M3NtUm00SXBIQnB"
);
String queryString = params.entrySet().stream()
.map(entry -> entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
String url = BASE_URL + ENDPOINT_PATH + "?" + queryString;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("x-api-key", API_KEY)
.header("Content-Type", "application/json")
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
return response.body();
} else {
throw new RuntimeException("HTTP " + response.statusCode() + ": " + response.body());
}
}
}This endpoint accepts the following parameters:
handleOptional(string)Can pass channelId or handle
Example: starterstory
channelIdOptional(string)Can pass channelId or handle
Example: UC-9-kyTW8ZkZNDHQJ6FgpwQ
sortOptional(select)Sort by newest or popular
Example: newest
continuationTokenOptional(string)Continuation token to get more videos. Get 'continuationToken' from previous response.
Example: 4qmFsgKrCBIYVUNkRkpXVWE0M3NtUm00SXBIQnB
Execute your script to test the API connection. You should see a JSON response with YouTube shorts 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,
"credits_remaining": 49998970118,
"videos": [],
"channels": [],
"playlists": [],
"shorts": [
{
"type": "short",
"id": "VREVC0wXPfs",
"url": "https://www.youtube.com/watch?v=VREVC0wXPfs",
"title": "This idea validation formula has made him $500K from iOS apps",
"thumbnail": "https://img.youtube.com/vi/VREVC0wXPfs/maxresdefault.jpg",
"viewCountText": "17,066",
"viewCountInt": 17066,
"description": "Most founders think their app isn’t selling because of market conditions.\n\nIt’s not.\n\nThis founder sold multiple apps and noticed the same pattern every time: Great products but broken deals.\n\nNot because the app was bad but because founders overcomplicate operations and chase the highest price instead of the fastest close.",
"commentCountText": "2",
"commentCountInt": 2,
"likeCountInt": 495,
"likeCountText": "495",
"publishDate": "2026-04-22T10:44:35-07:00",
"genre": "People & Blogs",
"durationMs": 37000,
"durationFormatted": "00:00:37"
},
{
"type": "short",
"id": "LUTxdXW4TUI",
"url": "https://www.youtube.com/watch?v=LUTxdXW4TUI",
"title": "$30M founder reveals the ideas he’d bet on again if he had to start over",
"thumbnail": "https://img.youtube.com/vi/LUTxdXW4TUI/maxresdefault.jpg",
"viewCountText": "18,917",
"viewCountInt": 18917,
"description": "$30M SaaS founder reveals 3 business ideas with massive potential.\n\nHe doesn’t chase “new ideas.”\n\nHe studies what’s already working… then adds a unique twist no one else thought of.\n\nIt’s all about:\n\nSpotting gaps competitors ignore\nMaking it ridiculously easy for customers to say yes\nExecuting better and faster than anyone else\n\nMost people overcomplicate. He keeps it simple… and profitable.",
"commentCountText": "11",
"commentCountInt": 11,
"likeCountInt": 712,
"likeCountText": "712",
"publishDate": "2026-03-28T11:25:20-07:00",
"genre": "People & Blogs",
"durationMs": 50000,
"durationFormatted": "00:00:50"
},
{
"type": "short",
"id": "1YGz9bkG7z0",
"url": "https://www.youtube.com/watch?v=1YGz9bkG7z0",
"title": "Founder of 2 profitable SaaS products shares his entire tech stack",
"thumbnail": "https://img.youtube.com/vi/1YGz9bkG7z0/maxresdefault.jpg",
"viewCountText": "16,393",
"viewCountInt": 16393,
"description": "He got nearly 1 million website visitors** without spending a single dollar on ads.\n\nMost builders think marketing means ads, cold emails, or posting on social media every day.\n\nBut this developer grew a SaaS to $13K MRR and another one to $6K/month before selling without these things.",
"commentCountText": "4",
"commentCountInt": 4,
"likeCountInt": 516,
"likeCountText": "516",
"publishDate": "2026-03-24T09:18:13-07:00",
"genre": "People & Blogs",
"durationMs": 51000,
"durationFormatted": "00:00:51"
},
{
"type": "short",
"id": "19ZP3japTsE",
"url": "https://www.youtube.com/watch?v=19ZP3japTsE",
"title": "Founder breaks down his 5 apps making $700K/month 🤯",
"thumbnail": "https://img.youtube.com/vi/19ZP3japTsE/maxresdefault.jpg",
"viewCountText": "11,923",
"viewCountInt": 11923,
"description": "Most founders dream about one successful app.\nThis guy built five.\n\nNot viral luck.\nNot overnight success.\nJust systems, playbooks, and ruthless execution.",
"commentCountText": "12",
"commentCountInt": 12,
"likeCountInt": 498,
"likeCountText": "498",
"publishDate": "2026-03-23T12:35:18-07:00",
"genre": "People & Blogs",
"durationMs": 75000,
"durationFormatted": "00:01:15"
},
{
"type": "short",
"id": "8PW-9Zr_W5g",
"url": "https://www.youtube.com/watch?v=8PW-9Zr_W5g",
"title": "He built 28 apps. They make $10K/month. Same tech stack every time.",
"thumbnail": "https://img.youtube.com/vi/8PW-9Zr_W5g/maxresdefault.jpg",
"viewCountText": "67,291",
"viewCountInt": 67291,
"description": "I asked this dev making $10K/month from 28 apps… here’s his tech stack 😳\n\nHe went from $200/month → $10K/month in 8 months.",
"commentCountText": "11",
"commentCountInt": 11,
"likeCountInt": 1733,
"likeCountText": "1733",
"publishDate": "2026-03-14T17:03:28-07:00",
"genre": "People & Blogs",
"durationMs": 35000,
"durationFormatted": "00:00:35"
}
],
"shelves": [],
"lives": [],
"continuationToken": "4qmFsgK7DBIY....."
}Check that your response includes the expected fields:
success(boolean)credits_remaining(number)videos(object)channels(object)playlists(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 shorts, consider batching requests to maximize throughput while staying within rate limits.
Use asynchronous processing in Java to handle multiple requests concurrently and improve overall performance.
Analyze YouTube shorts to understand market trends, competitor analysis, and audience insights.
Track performance metrics, engagement rates, and content trends across YouTube shorts.
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 Java HTTP concepts that work with any framework. The API calls remain the same regardless of your specific Java setup.
For large datasets, implement pagination, use streaming responses where available, and consider storing data in a database for efficient querying.
Ready to ship?
100 free API calls. No credit card. Same endpoint, same response shape.
Same endpoint, different language