Using Youtube API

John Zhang
Nov 3, 2020

I Youtube a lot, so it comes to no surprise that since learning to code I want to play around with Youtube in my Apps. This is how I went about doing so.

First I when to this website https://console.developers.google.com and signed up with a google account as necessary.

After signing in, go to the “Credentials” on the left

Then click “Create Credentials” and then “API Key”.

This will give you a key that you will need to access the API. Next step when fetching to access specifics from youtube, you’ll use this URL: https://www.googleapis.com/youtube/v3/

Following this is what you would like to use the API Key for, I used it for searching with a search term which used an URL like this https://www.googleapis.com/youtube/v3/search?part=snippet&key= < api key > &q= < search term >

ex: https://www.googleapis.com/youtube/v3/search?part=snippet&q=offlinetv&key= < API key >

Which when used as is provides a default of 5 results, a setting that can be changed by adding “&maxResults= < number between 1–50 >”. 50 being the strict maximum.

To access additional results after the first set, add a “pageToken= < nextPageToken >”, the nextPageToken provided by the initial fetch.

To access a specific playlist through the Youtube API, it is fairly similar like this: https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId= < Playlist ID > &key= < api key >

The playlist ID is found within the URL of a Youtube Playlist such as “PLuF8GDJO9aZLEdVIiCJQgkEeHSocIEy5r” of this playlist URL: https://www.youtube.com/playlist?list=PLuF8GDJO9aZLEdVIiCJQgkEeHSocIEy5r

Beyond these changes, the pageToken and maxResults work similarly for both.

--

--