Search code examples
apiyoutubepreview

Using YouTube's API to Render Preview


I'm working on a personal project and need to render a preview of a Youtube video by the URL similar to how Facebook pulls the preview thumbnail and title/description.

Wondering if someone can point me in the right direction; does the API allow for this?


Solution

  • In the YouTube V3 API, the video resource has a snippet property with the information you would need to do this. The snippet.thumbnails property is an object that provides image URLs in various sizes. The snippet.title property provides the title and the snippet.description property provides the description.

    A sample request would be:

    GET https://www.googleapis.com/youtube/v3/videos?part=id,snippet&id=VIDEO-ID&key=YOUR-API-KEY

    For more information, see YouTube's API documentation regarding the video object.