video_idstringbắt buộc
Video ID, get it from the URL, for example: https://www.youtube.com/watch?v=LuIL5JATZsc, the id is LuIL5JATZsc.
https://api.sandbase.ai/v1/api/youtube/web/relate-videoReturns a list of related videos for a given YouTube video ID. Supports pagination using a continuation token to retrieve additional recommendations.
[
{
"data": {
"continuation_token": "CBQSKRILTHVJTDVKQVRac2PAAQDIAQDgAQGiAg0o____________AUAA-AIAGAAqnwZNZ3NJemN6bHdMR3p4OEdKQWRyT2ktc013d1FLd0FRS0FfSS1BQW9Od2o0S0NLNmU2OWUzeTVqc0JBb0Q4ajRBQ2c3Q1Bnc0lsSlhOc01iTnBvWDlBUW9EOGo0QUNnN0NQZ3NJNlBHSTFQT2J6N2VQQVFvRDhqNEFDZzNDUGdvSWtkSDc1bzdSOHNnSUNnUHlQZ0FLRHNJLUN3aW5vb2lPeHRPaDdZd0JDZ1B5UGdBS0RjSS1DZ2pEeFBhcm9aZWo1ME1LQV9JLUFBb093ajRMQ01XbV81VDdwTHp3eGdFS0FfSS1BQW9Pd2o0TENJejQ4WnZ0bGZqLWhBRUtBX0ktQUFvT3dqNExDTF9rdHB6YmhvbVhfUUVLQV9JLUFBb053ajRLQ0pMTDN0cWV6X3YwTmdvRDhqNEFDZzNDUGdvSWlacnV1NDZCc0pRS0NnUHlQZ0FLRHNJLUN3amM4WS1Xal8ydnNJb0JDZ1B5UGdBS0RjSS1DZ2lGcHQ2SnlMYVZ6M1FLQV9JLUFBb053ajRL…",
"number_of_videos": 20,
"videos": [
{
"author": "CozyCraft",
"category": null,
"channel_id": "UCeu6U67OzJhV1KwBansH3Dg",
"description": "",
"is_live_content": null,
"keywords": [],
"number_of_views": 525000,
"published_time": "9 months ago",
"thumbnails": [
{
"height": 94,
"url": "https://i.ytimg.com/vi/BNhiW3r6zy4/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBgILLgwTXfFLQu976RwlbLa-UrBA",
"width": 168
},
{
"height": 188,
"url": "https://i.ytimg.com/vi/BNhiW3r6zy4/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBHrP5fLfb3Rg_Fk-fdvd6j3Yz3EQ",
"width": 336
}
],
"title": "🍃 slow down and simply be… (minecraft music w/ ambience)",
"type": "NORMAL",
"video_id": "BNhiW3r6zy4",
"video_length": "8:00:00"
},
{
"author": "Olde World Melodies",
"category": null,
"channel_id": "UCZ33CxqWeIjrFQaXrbA1_aQ",
"description": "",
"is_live_content": null,
"keywords": [],
"number_of_views": 19000000,
"published_time": "1 year ago",
"thumbnails": [
{
"height": 94,
"url": "https://i.ytimg.com/vi/_QqabGYTSpQ/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBErFvqh7G0sVV8HRU6tb39keqflQ",
"width": 168
},
{
"height": 188,
"url": "https://i.ytimg.com/vi/_QqabGYTSpQ/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLAo-VvH7jlYhAqDKcPOOC6Q_Nr6gA",
"width": 336
}
],
"title": "Midnight Vale - Peaceful Fantasy Ambience & Music | 10,000 Special",
"type": "NORMAL",
"video_id": "_QqabGYTSpQ",
"video_length": "1:50:58"
},
{
"author": "CozyCraft",
"category": null,
"channel_id": "UCeu6U67OzJhV1KwBansH3Dg",
"description": "",
"is_live_content": null,
"keywords": [],
"number_of_views": 26000,
"published_time": "1 year ago",
"thumbnails": [
{
"height": 94,
"url": "https://i.ytimg.com/vi/j2883zqCOOg/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLCVVAGxwR2TIyfzDduJq0eV6_NlLQ",
"width": 168
},
{
"height": 188,
"url": "https://i.ytimg.com/vi/j2883zqCOOg/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLA2gXO0Q8aTOzFvXnRBPa2MyI-qwg",
"width": 336
}
],
"title": "the air is warm, the breeze is light... (minecraft music & ambience)",
"type": "NORMAL",
"video_id": "j2883zqCOOg",
"video_length": "8:00:00"
},
"… 17 more items in the full response"
]
}
}
]Chọn một ví dụ để nạp đầu vào và kết quả của nó vào playground.
Returns a list of videos that YouTube recommends next to a given video. You send a video_id and get back each related video's title, channel, length, publish age and thumbnails, plus a token for the next page.
curl -X POST "https://api.sandbase.ai/v1/api/youtube/web/relate-video" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"video_id": "LuIL5JATZsc"}'
The result is returned in outputs[0].data.
| Name | Type | Required | Description |
|---|---|---|---|
video_id | string | Yes | Video ID, get it from the URL, for example: https://www.youtube.com/watch?v=LuIL5JATZsc, the id is LuIL5JATZsc. |
continuation_token | string | No | Token to continue fetching related videos. Default is None. |
Real response for the request above, trimmed: lists keep their first item and long strings are cut.
{
"continuation_token": "CBQSKRIL…",
"number_of_videos": 20,
"videos": [
{
"author": "CozyCraft",
"category": null,
"channel_id": "UCeu6U67OzJhV1KwBansH3Dg",
"description": "",
"is_live_content": null,
"keywords": [],
"number_of_views": 0,
"published_time": "6mo ago",
"thumbnails": [
{
"height": 94,
"url": "https://i.ytimg.com/vi/CijACOd7jQk/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDgg…",
"width": 168
}
],
"title": "just relax, everything can wait… (minecraft music & ambience)",
"type": "NORMAL",
"video_id": "CijACOd7jQk"
}
]
}
| Field | Meaning |
|---|---|
videos[].video_id | ID of the related video. Use it as video_id in other YouTube calls. |
videos[].title | Title of the related video. |
videos[].author / videos[].channel_id | Name and channel ID of the channel that posted the related video. |
videos[].video_length | Length of the video as a clock string, such as 11:00:00. |
videos[].published_time | Relative publish age as text, such as 6mo ago or 13d ago. It is not an exact date. |
videos[].number_of_views | View count of the related video. The sample shows 0 for every item, so do not rely on it. |
videos[].thumbnails[] | Thumbnail images with url, width and height. Each video lists two sizes. |
videos[].type | Kind of item. The sample shows NORMAL. |
number_of_videos | Count of videos returned in this page. |
continuation_token | Token that loads the next page of related videos. |
video_id from the watch URL. In https://www.youtube.com/watch?v=LuIL5JATZsc, the ID is LuIL5JATZsc.video_id with the continuation_token from the previous response.category, is_live_content, description and keywords are null or empty. Call YouTube Video Details for a related video to get fuller data.channel_id from this response to YouTube Channel Information.$0.001 per successful call. Failed calls are not charged. It is included in the daily free quota of each organization.
Bắt đầu xây dựng
Endpoint API của nền tảng với xác thực và theo dõi mức sử dụng thống nhất.
curl -X POST "https://api.sandbase.ai/v1/api/youtube/web/relate-video" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"video_id": "LuIL5JATZsc"
}'Đặt SandBase API key của bạn trong môi trường máy chủ. Các request sử dụng xác thực Bearer.
export SANDBASE_API_KEY="YOUR_API_KEY"Giữ key của bạn trên máy chủ. Không hiển thị trong mã chạy trên trình duyệt.
video_idstringbắt buộcVideo ID, get it from the URL, for example: https://www.youtube.com/watch?v=LuIL5JATZsc, the id is LuIL5JATZsc.
continuation_tokenstringToken to continue fetching related videos. Default is None.
Đây là phản hồi ví dụ đã lưu cho API này; không có request thực nào được gửi khi xem mục này.
[
{
"data": {
"continuation_token": "CBQSKRILTHVJTDVKQVRac2PAAQDIAQDgAQGiAg0o____________AUAA-AIAGAAqnwZNZ3NJemN6bHdMR3p4OEdKQWRyT2ktc013d1FLd0FRS0FfSS1BQW9Od2o0S0NLNmU2OWUzeTVqc0JBb0Q4ajRBQ2c3Q1Bnc0lsSlhOc01iTnBvWDlBUW9EOGo0QUNnN0NQZ3NJNlBHSTFQT2J6N2VQQVFvRDhqNEFDZzNDUGdvSWtkSDc1bzdSOHNnSUNnUHlQZ0FLRHNJLUN3aW5vb2lPeHRPaDdZd0JDZ1B5UGdBS0RjSS1DZ2pEeFBhcm9aZWo1ME1LQV9JLUFBb093ajRMQ01XbV81VDdwTHp3eGdFS0FfSS1BQW9Pd2o0TENJejQ4WnZ0bGZqLWhBRUtBX0ktQUFvT3dqNExDTF9rdHB6YmhvbVhfUUVLQV9JLUFBb053ajRLQ0pMTDN0cWV6X3YwTmdvRDhqNEFDZzNDUGdvSWlacnV1NDZCc0pRS0NnUHlQZ0FLRHNJLUN3amM4WS1Xal8ydnNJb0JDZ1B5UGdBS0RjSS1DZ2lGcHQ2SnlMYVZ6M1FLQV9JLUFBb053ajRL…",
"number_of_videos": 20,
"videos": [
{
"author": "CozyCraft",
"category": null,
"channel_id": "UCeu6U67OzJhV1KwBansH3Dg",
"description": "",
"is_live_content": null,
"keywords": [],
"number_of_views": 525000,
"published_time": "9 months ago",
"thumbnails": [
{
"height": 94,
"url": "https://i.ytimg.com/vi/BNhiW3r6zy4/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBgILLgwTXfFLQu976RwlbLa-UrBA",
"width": 168
},
{
"height": 188,
"url": "https://i.ytimg.com/vi/BNhiW3r6zy4/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBHrP5fLfb3Rg_Fk-fdvd6j3Yz3EQ",
"width": 336
}
],
"title": "🍃 slow down and simply be… (minecraft music w/ ambience)",
"type": "NORMAL",
"video_id": "BNhiW3r6zy4",
"video_length": "8:00:00"
},
{
"author": "Olde World Melodies",
"category": null,
"channel_id": "UCZ33CxqWeIjrFQaXrbA1_aQ",
"description": "",
"is_live_content": null,
"keywords": [],
"number_of_views": 19000000,
"published_time": "1 year ago",
"thumbnails": [
{
"height": 94,
"url": "https://i.ytimg.com/vi/_QqabGYTSpQ/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBErFvqh7G0sVV8HRU6tb39keqflQ",
"width": 168
},
{
"height": 188,
"url": "https://i.ytimg.com/vi/_QqabGYTSpQ/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLAo-VvH7jlYhAqDKcPOOC6Q_Nr6gA",
"width": 336
}
],
"title": "Midnight Vale - Peaceful Fantasy Ambience & Music | 10,000 Special",
"type": "NORMAL",
"video_id": "_QqabGYTSpQ",
"video_length": "1:50:58"
},
{
"author": "CozyCraft",
"category": null,
"channel_id": "UCeu6U67OzJhV1KwBansH3Dg",
"description": "",
"is_live_content": null,
"keywords": [],
"number_of_views": 26000,
"published_time": "1 year ago",
"thumbnails": [
{
"height": 94,
"url": "https://i.ytimg.com/vi/j2883zqCOOg/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLCVVAGxwR2TIyfzDduJq0eV6_NlLQ",
"width": 168
},
{
"height": 188,
"url": "https://i.ytimg.com/vi/j2883zqCOOg/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLA2gXO0Q8aTOzFvXnRBPa2MyI-qwg",
"width": 336
}
],
"title": "the air is warm, the breeze is light... (minecraft music & ambience)",
"type": "NORMAL",
"video_id": "j2883zqCOOg",
"video_length": "8:00:00"
},
"… 17 more items in the full response"
]
}
}
]Khám phá thêm
| API | Giá | Phản hồi |
|---|---|---|
YouTube Related Videos (Web)API này YouTube | $0.001 mỗi lần gọi | JSON |
YouTube | $0.001 mỗi lần gọi | JSON |
YouTube | $0.001 mỗi lần gọi | JSON |
YouTube | $0.001 mỗi lần gọi | JSON |
YouTube | $0.001 mỗi lần gọi | JSON |
YouTube | $0.001 mỗi lần gọi | JSON |
Câu hỏi
Gửi yêu cầu POST đến https://api.sandbase.ai/v1/api/youtube/web/relate-video với khóa API SandBase của bạn trong tiêu đề Authorization (Bearer) và các tham số trong phần thân JSON. Bạn cũng có thể thử trực tiếp trong Playground trên trang này mà không cần viết code.
$0.001 mỗi lần gọi, được tính từ số dư SandBase của bạn. Bạn chỉ bị tính phí cho các lần gọi bạn thực hiện; không có gói đăng ký.
Bắt buộc: video_id (string). Tùy chọn: continuation_token (string). Bảng Parameters và Playground trên trang này liệt kê mọi trường.
Phản hồi JSON được trả về trong cùng một yêu cầu HTTP (đồng bộ). README trên trang này có ví dụ phản hồi.
Không. YouTube Related Videos (Web) chạy thông qua SandBase, nên chỉ cần một API key SandBase là đủ cho endpoint này và mọi API cùng model khác trong danh mục. Bạn không cần đăng ký riêng để có quyền truy cập API của YouTube.