YouTube API
Related Videos
Get related/recommended videos for any YouTube video.
POST
$0.01/call/v1/youtube/relatedUsage
const res = await fetch('https://api.yepapi.com/v1/youtube/related', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: 'dQw4w9WgXcQ' }),
});
const { data } = await res.json();
console.log(data.data); // array of related videoscurl -X POST https://api.yepapi.com/v1/youtube/related \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": "dQw4w9WgXcQ"}'Request Body
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
id | string | Yes | YouTube video ID | — |
token | string | No | Continuation token for pagination | — |
Response
{
"ok": true,
"data": {
"meta": {
"videoId": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up",
"viewCount": "1756095483",
"channelTitle": "Rick Astley"
},
"data": [
{
"type": "video",
"videoId": "abc123",
"title": "Related Video Title",
"channelTitle": "Channel Name",
"viewCount": "5000000",
"lengthText": "4:12"
}
]
}
}Response Fields
| Field | Type | Description |
|---|---|---|
ok | boolean | Whether the request succeeded |
data.meta | object | Metadata about the source video |
data.meta.videoId | string | YouTube video ID of the source video |
data.meta.title | string | Title of the source video |
data.meta.viewCount | string | Total view count of the source video |
data.meta.channelTitle | string | Channel name of the source video |
data.data | object[] | Array of related video results |
data.data[].type | string | Content type (e.g., video) |
data.data[].videoId | string | YouTube video ID of the related video |
data.data[].title | string | Title of the related video |
data.data[].channelTitle | string | Channel name of the related video |
data.data[].viewCount | string | View count of the related video |
data.data[].lengthText | string | Video duration in human-readable format |