Building a YouTube integration usually means answering three questions: what is this video, what are viewers saying, and what should they watch next? By the end of this guide, you can call the Youtube Data API for video details, recent comments, and related videos, then use the returned fields in a Python application.
What the Youtube Data API returns
The Youtube Data API exposes three GET endpoints for working with a video ID. Video Details returns information such as the title, description, publication date, view count, comment count, and likes. Video Comments returns recent comments, including their text, author, creation date, and likes. Similar Videos returns a list of related videos.
These operations fit applications such as video discovery interfaces, creator dashboards, and editorial research tools. For example, an application can load a video's details, display related titles alongside it, and present recent comments for a researcher to review.
Getting started on Zyla API Hub
Open the Youtube Data API listing on Zyla API Hub, create a free account if needed, and select Subscribe or Start Free Trial when available. Get your API key from your account and use it in the Authorization: Bearer YOUR_API_KEY header.
Zyla uses subscriptions and quotas rather than pay-per-call billing. The first API has a 7-day trial or 50 requests; check the API page for current access options and pricing. The marketplace has more than 10,000 public APIs, with one account and API key for access across the Hub.
Available endpoints
All three operations use GET requests and the same Bearer authentication header. The URLs below are the Hub request URLs; supply only the parameters documented for the operation you call.
Similar Videos
GET https://zylalabs.com/api/14/youtube-data-api/56/similar-videos
Provide a video ID to receive a list of similar videos. The request parameters are:
relatedToVideoId— required string containing the source video ID, such as7ghhRHRP6t4.part— required string; the documented example usesid,snippet.type— required string; the documented example usesvideo.maxResults— optional string; the documented example uses50.
The returned items contain video identifiers and snippets. The example response also includes pageInfo and nextPageToken, which are useful for understanding the result set.
Video Comments
GET https://zylalabs.com/api/14/youtube-data-api/61/video-comments
Retrieve a list of the latest comments for a video. The required string parameters are part, videoId, and maxResults; the documented values are snippet, 7ghhRHRP6t4, and 100, respectively.
The documented response nests the comment under snippet.topLevelComment.snippet. Fields there include textDisplay, textOriginal, authorDisplayName, likeCount, publishedAt, and updatedAt. A comment thread also includes totalReplyCount; use it as a count, not as the text of the replies.
Video Details
GET https://zylalabs.com/api/14/youtube-data-api/62/video-details
Retrieve details for a video by passing the required string parameter id. The documented example uses 7ghhRHRP6t4. The response includes an items array with a video id and a snippet containing fields such as title, description, publishedAt, and channelId.
This endpoint also provides information such as views, comments, and likes. Use the API listing when integrating those values rather than assuming field paths from the Similar Videos response.
Call Similar Videos and read the results
This request uses the documented video ID and asks for the id and snippet parts. Replace YOUR_API_KEY with your Hub key before running it.
curl -s -X GET "https://zylalabs.com/api/14/youtube-data-api/56/similar-videos?relatedToVideoId=7ghhRHRP6t4&part=id%2Csnippet&type=video&maxResults=50" \
-H "Authorization: Bearer YOUR_API_KEY"
The official response excerpt starts as follows. It is truncated within the first item's thumbnail data, so it illustrates the returned fields but is not a complete JSON document to paste into a parser.
{"kind":"youtube#searchListResponse","nextPageToken":"CDIQAA","pageInfo":{"totalResults":108,"resultsPerPage":50},"items":[{"kind":"youtube#searchResult","id":{"kind":"youtube#video","videoId":"mj0XInqZMHY"},"snippet":{"publishedAt":"2019-06-27T14:44:32Z","channelId":"UC0C-w0YjGpqDXGB8IHb662A","title":"Ed Sheeran - Beautiful People (feat. Khalid) [Official Music Video]","description":"The official music video for Ed Sheeran - Beautiful People (feat. @khalid)\nSubtract, the new album, out 05.05.2023. Pre-order: https://es.lnk.to/subtract\n \nTaken from No.6 Collaborations Project released in 2019, which featured the hit singles 'I Don't Care', 'Cross Me', 'Beautiful People', 'Blow', 'Best Part of Me', 'Antisocial', 'South of the Border' &'Take Me Back To London'. \n \nSubscribe to the Ed Sheeran channel for all the best and latest official music videos, behind the scenes and live performances. \nhttp://bit.ly/SubscribeToEdSheeran \n \nSee more official videos from Ed Sheeran here: \nhttps://www.youtube.com/watch?v=ryJgDL9jzKk&list=PLjp0AEEJ0-fGKG_3skl0e1FQlJfnx-TJz \n\nListen to more from the No. 6 Collaborations Project here : \nhttps://www.youtube.com/playlist?list=PLjp0AEEJ0-fHZDWhxhKo0wG08bMUcRy3l\n \nFollow Ed Sheeran on: \nInstagram: http://instagram.com/teddysphotos\nTikTok: https://www.tiktok.com/@edsheeran\nFacebook: http://www.facebook.com/EdSheeranMusic\nTwitter: http://twitter.com/edsheeran\nDiscord: http://discord.gg/edsheeran\nOfficial Website: http://edsheeran.com \n\nAbout Ed Sheeran: \nEd Sheeran may be the quintessential pop star of the 2010s: an internationally acclaimed, multi-award winning singer/songwriter who seems to acknowledge no boundaries between styles or eras of music. \n\nHis incredible catalogue includes the studio albums ‘+’ (plus), ‘x’ (multiply) and ‘÷’ (divide) which spawned hit singles such as ‘The A team’ , ’Lego House’, ‘Sing', ‘Thinking Out Loud’, ‘Photograph’, ‘Shape Of You’, ‘Castle on The Hill’ and ‘Perfect’. \n \nIn 2019, Ed Sheeran released the genre-spanning ‘No.6 Collaborations Project’ which featured a wide-range of artists including ‘Justin Bieber’, ‘Camilla’ Cabello’, ‘Travis Scott’, ‘Eminem’, ‘Cardi B, ‘Paulo Londra’, ‘Bruno Mars’ and ‘Stormzy’ amongst many others, producing hits such as ‘I Don’t Care’, ‘Beautiful People’, ‘South of The Border’ and ‘Take Me Back To London’. \n \n#EdSheeran #Khalid #BeautifulPeople","thumbnails":{"…
For each entry in items, use id.videoId as the related video's identifier and snippet.title as its display title. The snippet also includes publishedAt and channelId. The trailing Z in the example timestamp denotes UTC.
pageInfo.totalResults and pageInfo.resultsPerPage describe the result set, while nextPageToken appears in the example. Treat the token as response data: the supplied endpoint parameters do not specify how to request a subsequent page.
Python example
The following sample calls the same endpoint with the same parameters and prints each returned video ID and title. It uses Python's standard library and reads the complete response from the API, not the truncated excerpt above.
import json
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
url = (
"https://zylalabs.com/api/14/youtube-data-api/56/similar-videos"
"?relatedToVideoId=7ghhRHRP6t4&part=id%2Csnippet"
"&type=video&maxResults=50"
)
request = Request(
url,
headers={"Authorization": "Bearer YOUR_API_KEY"},
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
data = json.load(response)
except HTTPError as error:
raise SystemExit(f"API request failed: HTTP {error.code}")
except URLError as error:
raise SystemExit(f"Could not reach the API: {error.reason}")
for item in data.get("items", []):
video_id = item.get("id", {}).get("videoId")
title = item.get("snippet", {}).get("title")
if video_id and title:
print(f"{video_id}: {title}")
The sample tolerates an absent items array and skips entries without an ID or title. In an application, distinguish an empty list from a failed request so the interface does not present an error as “no related videos.” Keep the API key in server-side configuration rather than exposing it in a client-side application.
Practical use cases
Build a related-video panel
When a user opens a video page, call Similar Videos with that video's ID. Render each returned snippet.title and retain id.videoId so a selection can identify the next video. The returned channelId and publication timestamp can provide additional context.
Cache the result for a period appropriate to the application instead of requesting the same list on every page render. Related results can change, so make the cache refreshable and avoid treating a cached list as permanent.
Support creator and editorial research
Use Video Details to put a video's title, description, publication date, and engagement information in one place. An editorial team can use that context to decide which videos to review; a creator dashboard can show the same information alongside other data already in the application.
Store the video ID with any cached result so that details do not become detached from the source video. Treat view, comment, and like counts as observations that can change, not immutable properties of the video.
Review recent audience feedback
Call Video Comments for the video under review and display the comment text, author, creation date, and like count. Those fields help a team scan recent feedback without reducing every comment to a single score.
The documented response contains both textDisplay and textOriginal. Choose the field appropriate to your presentation and handle returned text as untrusted content when rendering it. The thread's reply count is useful context, but the documented request does not describe a separate operation for retrieving replies.
Use the API from an AI agent
Zyla APIs can also be called through the MCP endpoint. Configure an MCP-compatible client, such as Claude Code, Cursor, or Windsurf, with https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY, replacing the placeholder with your Hub key.
An agent can use the available API operations in a workflow such as gathering a video's details and recent comments for review. Check the client and Hub tool documentation for the exact tool interface, and avoid putting the key in prompts or shared logs.
FAQ
How do I find videos similar to a YouTube video?
Call Similar Videos with the source ID in relatedToVideoId, plus the required part and type parameters. Read each related ID from items[].id.videoId and its title from items[].snippet.title.
Can I retrieve the latest comments for a video?
Yes. Call Video Comments with part, videoId, and maxResults. The documented response includes comment text, author, publication date, and like count.
Can I request another page using the returned token?
The example response includes nextPageToken, but the supplied request parameters do not define a pagination parameter. Check the API page before implementing requests for additional pages.
How is access billed?
Access uses a subscription and quota, not pay-per-call billing. The first API has a 7-day trial or 50 requests; check the listing for current access options and pricing.
Create a free Zyla account, get an API key, and Start 7-day trial on Youtube Data API from the marketplace listing.
Official API response
{"kind":"youtube#searchListResponse","nextPageToken":"CDIQAA","pageInfo":{"totalResults":108,"resultsPerPage":50},"items":[{"kind":"youtube#searchResult","id":{"kind":"youtube#video","videoId":"mj0XInqZMHY"},"snippet":{"publishedAt":"2019-06-27T14:44:32Z","channelId":"UC0C-w0YjGpqDXGB8IHb662A","title":"Ed Sheeran - Beautiful People (feat. Khalid) [Official Music Video]","description":"The official music video for Ed Sheeran - Beautiful People (feat. @khalid)\nSubtract, the new album, out 05.05.2023. Pre-order: https://es.lnk.to/subtract\n \nTaken from No.6 Collaborations Project released in 2019, which featured the hit singles 'I Don't Care', 'Cross Me', 'Beautiful People', 'Blow', 'Best Part of Me', 'Antisocial', 'South of the Border' &'Take Me Back To London'. \n \nSubscribe to the Ed Sheeran channel for all the best and latest official music videos, behind the scenes and live performances. \nhttp://bit.ly/SubscribeToEdSheeran \n \nSee more official videos from Ed Sheeran here: \nhttps://www.youtube.com/watch?v=ryJgDL9jzKk&list=PLjp0AEEJ0-fGKG_3skl0e1FQlJfnx-TJz \n\nListen to more from the No. 6 Collaborations Project here : \nhttps://www.youtube.com/playlist?list=PLjp0AEEJ0-fHZDWhxhKo0wG08bMUcRy3l\n \nFollow Ed Sheeran on: \nInstagram: http://instagram.com/teddysphotos\nTikTok: https://www.tiktok.com/@edsheeran\nFacebook: http://www.facebook.com/EdSheeranMusic\nTwitter: http://twitter.com/edsheeran\nDiscord: http://discord.gg/edsheeran\nOfficial Website: http://edsheeran.com \n\nAbout Ed Sheeran: \nEd Sheeran may be the quintessential pop star of the 2010s: an internationally acclaimed, multi-award winning singer/songwriter who seems to acknowledge no boundaries between styles or eras with elements of folk, hip-hop, pop, dance, soul, and rock woven throughout his music. \n\nHis incredible catalogue includes the studio albums ‘+’ (plus), ‘x’ (multiply) and ‘÷’ (divide) which spawned hit singles such as ‘The A team’ , ’Lego House’, ‘Sing', ‘Thinking Out Loud’, ‘Photograph’, ‘Shape Of You’, ‘Castle on The Hill’ and ‘Perfect’. \n \nIn 2019, Ed Sheeran released the genre-spanning ‘No.6 Collaborations Project’ which featured a wide-range of artists including ‘Justin Bieber’, ‘Camilla’ Cabello’, ‘Travis Scott’, ‘Eminem’, ‘Cardi B, ‘Paulo Londra’, ‘Bruno Mars’ and ‘Stormzy’ amongst many others, producing hits such as ‘I Don’t Care’, ‘Beautiful People’, ‘South of The Border’ and ‘Take Me Back To London’. \n \n#EdSheeran #Khalid #BeautifulPeople","thumbnails":{"…
Official API response
{"kind":"youtube#searchListResponse","nextPageToken":"CDIQAA","pageInfo":{"totalResults":108,"resultsPerPage":50},"items":[{"kind":"youtube#searchResult","id":{"kind":"youtube#video","videoId":"mj0XInqZMHY"},"snippet":{"publishedAt":"2019-06-27T14:44:32Z","channelId":"UC0C-w0YjGpqDXGB8IHb662A","title":"Ed Sheeran - Beautiful People (feat. Khalid) [Official Music Video]","description":"The official music video for Ed Sheeran - Beautiful People (feat. @khalid)\nSubtract, the new album, out 05.05.2023. Pre-order: https://es.lnk.to/subtract\n \nTaken from No.6 Collaborations Project released in 2019, which featured the hit singles 'I Don't Care', 'Cross Me', 'Beautiful People', 'Blow', 'Best Part of Me', 'Antisocial', 'South of the Border' &'Take Me Back To London'. \n \nSubscribe to the Ed Sheeran channel for all the best and latest official music videos, behind the scenes and live performances. \nhttp://bit.ly/SubscribeToEdSheeran \n \nSee more official videos from Ed Sheeran here: \nhttps://www.youtube.com/watch?v=ryJgDL9jzKk&list=PLjp0AEEJ0-fGKG_3skl0e1FQlJfnx-TJz \n\nListen to more from the No. 6 Collaborations Project here : \nhttps://www.youtube.com/playlist?list=PLjp0AEEJ0-fHZDWhxhKo0wG08bMUcRy3l\n \nFollow Ed Sheeran on: \nInstagram: http://instagram.com/teddysphotos\nTikTok: https://www.tiktok.com/@edsheeran\nFacebook: http://www.facebook.com/EdSheeranMusic\nTwitter: http://twitter.com/edsheeran\nDiscord: http://discord.gg/edsheeran\nOfficial Website: http://edsheeran.com \n\nAbout Ed Sheeran: \nEd Sheeran may be the quintessential pop star of the 2010s: an internationally acclaimed, multi-award winning singer/songwriter who seems to acknowledge no boundaries between styles or eras with elements of folk, hip-hop, pop, dance, soul, and rock woven throughout his music. \n\nHis incredible catalogue includes the studio albums ‘+’ (plus), ‘x’ (multiply) and ‘÷’ (divide) which spawned hit singles such as ‘The A team’ , ’Lego House’, ‘Sing', ‘Thinking Out Loud’, ‘Photograph’, ‘Shape Of You’, ‘Castle on The Hill’ and ‘Perfect’. \n \nIn 2019, Ed Sheeran released the genre-spanning ‘No.6 Collaborations Project’ which featured a wide-range of artists including ‘Justin Bieber’, ‘Camilla’ Cabello’, ‘Travis Scott’, ‘Eminem’, ‘Cardi B, ‘Paulo Londra’, ‘Bruno Mars’ and ‘Stormzy’ amongst many others, producing hits such as ‘I Don’t Care’, ‘Beautiful People’, ‘South of The Border’ and ‘Take Me Back To London’. \n \n#EdSheeran #Khalid #BeautifulPeople","thumbnails":{"…