YouTube API
YouTube Search
Search YouTube for videos, channels, and playlists with rich metadata.
POST
$0.01/call/v1/youtube/searchUsage
const res = await fetch('https://api.yepapi.com/v1/youtube/search', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ query: 'nextjs tutorial', type: 'video' }),
});
const { data } = await res.json();
console.log(data.data); // array of video resultscurl -X POST https://api.yepapi.com/v1/youtube/search \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "nextjs tutorial", "type": "video"}'Request Body
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
query | string | Yes | Search query | — |
type | string | No | Filter: video, channel, playlist | all |
sort | string | No | Sort: upload_date, view_count, rating | relevance |
duration | string | No | Duration filter | — |
upload_date | string | No | Upload date filter | — |
features | string | No | Feature filter | — |
geo | string | No | Country code (e.g. US) | — |
lang | string | No | Language code (e.g. en) | — |
token | string | No | Continuation token for pagination | — |
Response
{
"ok": true,
"data": {
"estimatedResults": "675836",
"continuation": "EqQD...",
"data": [
{
"type": "video",
"videoId": "ZVnjOPwW4ZA",
"title": "Next js Tutorial for Beginners | Nextjs 13 (App Router) with TypeScript",
"channelTitle": "Programming with Mosh",
"channelId": "UCWv7vMbMWH4-V0ZXdmDpPBA",
"channelHandle": "@programmingwithmosh",
"channelBadges": ["Verified"],
"isVerifiedChannel": true,
"description": "Master Next.js 13 and build amazing full-stack apps! This beginner-friendly tutorial covers the new App Router, TypeScript, and ...",
"viewCount": "1275546",
"viewCountText": "1,275,546 views",
"publishDate": "2024-04-13",
"publishedAt": "2024-04-13T00:00:00Z",
"publishedTimeText": "2 years ago",
"lengthText": "1:02:55",
"thumbnail": [
{ "url": "https://i.ytimg.com/vi/ZVnjOPwW4ZA/hq720.jpg", "width": 360, "height": 202 },
{ "url": "https://i.ytimg.com/vi/ZVnjOPwW4ZA/hq720.jpg", "width": 720, "height": 404 }
],
"richThumbnail": [
{ "url": "https://i.ytimg.com/an_webp/ZVnjOPwW4ZA/mqdefault_6s.webp", "width": 320, "height": 180 }
],
"channelThumbnail": [
{ "url": "https://yt3.ggpht.com/...=s68-c-k-c0x00ffffff-no-rj", "width": 68, "height": 68 }
]
}
]
}
}Response Fields
| Field | Type | Description |
|---|---|---|
ok | boolean | Whether the request succeeded |
data.estimatedResults | string | Estimated total number of matching results |
data.continuation | string | Token to fetch the next page of results |
data.data | object[] | Array of search results |
data.data[].type | string | Result type: video, channel, or playlist |
data.data[].videoId | string | Unique YouTube video identifier |
data.data[].title | string | Video title as displayed on YouTube |
data.data[].channelTitle | string | Name of the channel that uploaded the video |
data.data[].channelId | string | Unique identifier for the channel |
data.data[].channelHandle | string | Channel handle (e.g. @programmingwithmosh) |
data.data[].channelBadges | string[] | Channel verification badges (e.g. Verified) |
data.data[].isVerifiedChannel | boolean | Whether the channel is verified |
data.data[].description | string | Snippet of the video description shown in search results |
data.data[].viewCount | string | Raw view count as a numeric string |
data.data[].viewCountText | string | Human-readable view count (e.g. 1,275,546 views) |
data.data[].publishDate | string | Publish date in YYYY-MM-DD format |
data.data[].publishedAt | string | Publish date as ISO 8601 timestamp |
data.data[].publishedTimeText | string | Relative publish time (e.g. 2 years ago) |
data.data[].lengthText | string | Video duration in H:MM:SS or MM:SS format |
data.data[].thumbnail | object[] | Video thumbnail images at various resolutions |
data.data[].richThumbnail | object[] | Animated preview thumbnail (webp format) |
data.data[].channelThumbnail | object[] | Channel avatar images |
data.data[].badges | string[] | Video badges (e.g. 4K, CC, Beginner) |
Use the continuation token from the response as the token parameter to fetch the next page of results.