YouTube API Guide
From the variety of possible requests to YouTube servers we will review some interesting cases. This guide will cover the following topics:
- 1.How to get a Google APIs key?
- 2.How to run queries to YouTube servers in API Tester to:
- Get video data,
- Get channel data,
- Get a list of channel playlists,
- Get a list of comments,
If you need a detailed information about each request or you want to learn how to form other requests, then read the official documentation:
YouTube is part of Google's infrastructure. Usage of all of the Google APIs requires authentication and authorization using the Oauth 2.0 protocol.
Read about how to get the API key in the guide devoted to Google APIs:
LINK FOR OUR GOOGLE API GUIDE
Let's try to send a request to receive data about the video by its ID. Follow a few simple steps:
- 1.Launch API Tester and create a new request by tapping on the “plus” icon.
- 2.Select the GET request type.
- 3.Paste the endpoint address into the API Tester app:https://www.googleapis.com/youtube/v3/videos
- 4.Add the key parameter and set the API key generated in Google Cloud Platform as the value in the Query Params section. This parameter will be automatically added to the query string.
- 5.Add the "id" parameter with the value "LlvBzyy-558", this is the ID of the React Hooks tutorial video.
- 6.Add the "part" parameter with the value "snippet".
- 7.Tap the send request button.
The server will return information about the video:
To get data about the channel, you need the appropriate endpoint and channel ID. Other parameters remain unchanged relative to the previous request. In this example we will review the channel of a musician Alexandr Misko.
- 2.Channel id = UCdZe3OmKYiIwyrLFEEbNwVw.
Let's send a request and get detailed information about the channel!
To get a list of channel playlists, you need to do the following steps:
- 1.Insert a new endpoint:https://www.googleapis.com/youtube/v3/playlists
- 2.For this example we will use the information about channel "ReactJS Tips and Trics". Add the "channelId" parameter with the value "UC8S4rDRZn6Z_StJ-hh7ph8g".
Let's send a request and get an array of playlists data!
Another example of getting an array of YouTube data is getting a list of comments. To get this information, you need to do the following steps:
- 1.Insert a new endpoint:https://youtube.googleapis.com/youtube/v3/comments
- 2.Add the "parentId" parameter with the value "UgwRGZmC6iOsW_MnLlR4AaABAg".
Let's send a request and get an array of comments data!
Server returns a collection of search results that match the query parameters specified in the API request. By default, a search result set identifies matching video, channel, and playlist resources, but you can also configure queries to only retrieve a specific type of resource. Let's get the search results for "ReactNative".
Do the following steps:
- 1.Insert a new endpoint:https://youtube.googleapis.com/youtube/v3/search
- 2.Add the "q" parameter with the value "ReactNative".
Let's send a request and get a collection of search results!