YouTube Search API: Build Powerful Discovery Applications
Need to search YouTube programmatically? The Search API lets you find videos, channels, and playlists—perfect for content discovery and research tools.
Search Capabilities
| Endpoint | Description |
|---|---|
| Search | General video/channel search |
| Search Hashtag | Find videos by hashtag |
General Search API
Search for videos, channels, playlists, shorts, and lives:
const response = await fetch(
'https://api.sociavault.com/v1/scrape/youtube/search?query=web+scraping+tutorial&sortBy=relevance',
{
headers: {
'x-api-key': 'YOUR_API_KEY'
}
}
);
const results = await response.json();
Parameters
| Parameter | Required | Description |
|---|---|---|
query | Yes | Search query |
uploadDate | No | today, this_week, this_month, or this_year |
sortBy | No | relevance (default) or popular |
filter | No | all (default) or shorts (only works without uploadDate/sortBy) |
continuationToken | No | Token from previous response for pagination |
Sample Response
Results are grouped by type. Each group uses numeric keys — use Object.values() to iterate.
{
"success": true,
"data": {
"videos": {
"0": {
"type": "video",
"id": "HJr2BqCcz8g",
"url": "https://www.youtube.com/watch?v=HJr2BqCcz8g",
"title": "Web Scraping Tutorial 2026 - Complete Guide",
"thumbnail": "https://i.ytimg.com/vi/HJr2BqCcz8g/hq720.jpg",
"channel": {
"id": "UCJg9wBPyKMNA5sRDnvzmkdg",
"title": "Tech Channel",
"handle": "techchannel",
"thumbnail": "https://yt3.ggpht.com/..."
},
"viewCountText": "250,000 views",
"viewCountInt": 250000,
"publishedTimeText": "2 weeks ago",
"publishedTime": "2026-01-05T10:00:00Z",
"lengthText": "25:30",
"lengthSeconds": 1530,
"badges": {}
}
},
"channels": {},
"playlists": {},
"shorts": {
"0": {
"type": "short",
"id": "UhPc_k8DThI",
"url": "https://www.youtube.com/watch?v=UhPc_k8DThI",
"title": "Web scraping in 60 seconds #coding",
"viewCountText": "7.1K",
"viewCountInt": 7100
}
},
"shelves": {},
"lives": {},
"continuationToken": "ErkDEghmb290YmFsbB..."
},
"credits_used": 1
}
Hashtag Search
Find videos using a specific hashtag:
const response = await fetch(
'https://api.sociavault.com/v1/scrape/youtube/search/hashtag?hashtag=shorts&type=all',
{
headers: {
'x-api-key': 'YOUR_API_KEY'
}
}
);
const hashtagResults = await response.json();
Hashtag Parameters
| Parameter | Required | Description |
|---|---|---|
hashtag | Yes | Hashtag to search for (e.g. funny) |
continuationToken | No | Token from previous response for pagination |
type | No | all (default) or shorts |
The response has the same structure as general search — videos, channels, playlists, shorts, etc.
Use Cases
Content Research
Find videos on a topic:
async function researchTopics(topics) {
const research = await Promise.all(
topics.map(async query => {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/search?query=${encodeURIComponent(query)}`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const videos = Object.values(data.videos || {});
return {
topic: query,
totalVideos: videos.length,
avgViews: videos.length > 0
? videos.reduce((s, v) => s + (v.viewCountInt || 0), 0) / videos.length
: 0
};
})
);
console.log('Topic research:', research);
}
Competitor Content Analysis
Find competing content:
async function analyzeCompetition(searchTerms) {
for (const term of searchTerms) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/search?query=${encodeURIComponent(term)}&sortBy=popular`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const videos = Object.values(data.videos || {});
console.log(`\n"${term}" - ${videos.length} videos found`);
videos.slice(0, 5).forEach(v => {
console.log(`- ${v.title} (${v.viewCountText})`);
});
}
}
Hashtag Monitoring
Track content using specific hashtags:
async function monitorHashtags(hashtags) {
for (const tag of hashtags) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/search/hashtag?hashtag=${encodeURIComponent(tag)}`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const videos = Object.values(data.videos || {});
const shorts = Object.values(data.shorts || {});
const recentVideos = videos.filter(v =>
v.publishedTime && new Date(v.publishedTime) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)
);
console.log(`#${tag}: ${recentVideos.length} videos + ${shorts.length} shorts this week`);
}
}
Build a Content Calendar
Research what's performing to plan content:
async function buildCalendar(keywords) {
const insights = [];
for (const keyword of keywords) {
const res = await fetch(
`https://api.sociavault.com/v1/scrape/youtube/search?query=${encodeURIComponent(keyword)}&uploadDate=this_month`,
{ headers: { 'x-api-key': 'YOUR_API_KEY' } }
);
const { data } = await res.json();
const videos = Object.values(data.videos || {});
const avgViews = videos.length > 0
? videos.reduce((s, v) => s + (v.viewCountInt || 0), 0) / videos.length
: 0;
insights.push({
keyword,
avgViews,
competition: videos.length,
opportunity: videos.length > 0 ? avgViews / videos.length : 0
});
}
return insights.sort((a, b) => b.opportunity - a.opportunity);
}
Related Endpoints
- YouTube Channel Scraper - Channel details
- YouTube Videos Scraper - Channel videos
- YouTube Trending Shorts - Trending content
- TikTok Search - TikTok search
Frequently Asked Questions
How many results can I get?
Each search returns results grouped by type (videos, channels, playlists, shorts, lives). Use continuationToken from the response to paginate for more.
Can I filter by upload date?
Yes, use the uploadDate parameter with options: today, this_week, this_month, or this_year. You can also use sortBy (relevance or popular).
Are results personalized?
No, SociaVault returns non-personalized results, giving you objective search data.
Can I search for playlists?
Yes, playlists appear in general search results alongside videos and channels.
How does hashtag search work?
Hashtag search returns videos that include the specific hashtag in their title or description.
Get Started
Create your account and start searching YouTube programmatically.
Documentation: /docs/api-reference/youtube/search
Found this helpful?
Share it with others who might benefit
Ready to Try SociaVault?
Start extracting social media data with our powerful API. No credit card required.