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,

  • Search.

If you need a detailed information about each request or you want to learn how to form other requests, then read the official documentation:

https://developers.google.com/youtube/v3/docs

How to get a YouTube API key?

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 

Get YouTube video data

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:

Note! You can view the video id at the end of the video URL: https://youtu.be/LlvBzyy-558

You can import this request into API Tester app via these links:

Get channel data

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.

  1. Endpoint:

     https://www.googleapis.com/youtube/v3/channels
  2. Channel id = UCdZe3OmKYiIwyrLFEEbNwVw.

Let's send a request and get detailed information about the channel!

You can import this request into API Tester app via these links:

Get a list of channel playlists

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!

You can import this request into API Tester app via these links:

Get a list of comments

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!

You can import this request into API Tester app via these links:

  • curl -X GET 'https://youtube.googleapis.com/youtube/v3/comments?part=snippet&parentId=UgwRGZmC6iOsW_MnLlR4AaABAg&key=AIzaSyAw84SRK6coxEtx9hYNwyoi6Cj6jG6dknc'

  • https://apitester.org/ieJw1y00LgjAcgHE:SGe9uUMyKpBYFiK9gRJRl1hzzPmyjfY3XZ8.D3V8fvAQz:MEh0R3HVdgtxToLKgAjF0h5HQP:ZOHQmvRcmqkDZnu:ozec8R.39rQF8RWSWM4.FNMmJXxRQx5eu8SLM:2.jiqQ5tHhJINEX7DXUyyDy0cGRZRke8x0.MOxmV1Ow1OS5zUuE5x2SgWfAEsgTrH

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!

You can import this request into API Tester app via these links:

  • curl -X GET 'https://youtube.googleapis.com/youtube/v3/search?part=snippet&q=ReactNative&key=AIzaSyAw84SRK6coxEtx9hYNwyoi6Cj6jG6dknc'

  • https://apitester.org/ieJxzZGBgiMwvDSlNSlUITk0sSs6QUc8oKSkottLXr8wvLQGK66Xn56fnpCYWZBbrJefnwoT1y4z1i8E67AsSi0psi:MyCwpSS9QKbYNSE5NL:BJLMstS1bJTK20dPasSgysdyy1MgoO8zZLzK1xLKiwzIv3KK:MzzZyzzLLczVKy85LVAaCQMfc

Last updated