Click here to Skip to main content
13,863,336 members
Click here to Skip to main content
Add your own
alternative version


8 bookmarked
Posted 24 Mar 2015
Licenced CC (ASA 3U)

Youtube Data API v3 on Android – Introduction

, 24 Mar 2015
Rate this:
Please Sign up or sign in to vote.
Introduction to Youtube Data API v3 on Android

First Things First

If you have ever developed an app that needs to obtain information from YouTube channels or videos, you probably noticed that querying the YouTube Data API v3 isn't that simple, and can cause more than a headache at the beginning.

In order to facilitate the use of this API, I'm going to write a series of articles with the basics, so you can understand how the queries work and make your own app in no time, starting from this post, that is a brief introduction.

Youtube Data API v3, What Is It?

Youtube logo

YouTube offers a public URL (, known as Data API, so applications, websites, etc. can read the public information from YouTube channels and videos (also read / write private information, loging first in the OAuth System), and at the same time, it has an Android (and other OS) specific APIs, that allows you to generate, without effort, video players, preview images, layouts, etc. in your APP.

Analyzing the previous versions of the Data API, v3 has been restructured to recover only the specific pieces of information needed, instead of all the channel / video data, avoiding an enormous consumption of server resources for YouTube, and a waste of time for you, waiting for all the data to be retrieved, and the consequent post-processing of the data to get just what you need and discard the rest.

The basic way to communicate with YouTube Data API v3 is trough HTTP queries to the public URL. Google also offers a website called the Youtube API Explorer, that allows you to make test queries to the Data API specifying the info you want to retrieve:

HTTP Request Diagram

The problem we face here is that Android API is not intended to recover information, but to show it, and don't expose direct methods to access the Data API, so we have to manually execute HTTP queries to the public URL sending different GET parameters (See also Query Strings article on Wikipedia the understand URL parameters) depending on the information we want to retrieve, a process that is not simple and requires a certain level of knowledge of the platform / language we are working with.

Before Finishing, A Simple Example

I don't want to extend the introduction much more, let's see a small example using the API explorer website from Google.

If we access the following URL and press the Execute button, we can obtain the basic data from Murata Shinya's YouTube channel, please take a moment to look at the form to see the parameters I chose and how I filled them out, the data retrieved will be useful so we can later obtain, for example, the video list of the channel:

The real URL you would use in a manual HTTP query to obtain that information, is this one:{YOUR_API_KEY}

Let's analyze briefly the parameters used in the above URL:


"part=contentDetails" : Specifies the "piece" of information we want to retrieve, "contentDetails" asks for just the details of the element, we could fill the part parameter with other options such as "id" (Retrieves just the channel ID), snippet (Title and description), among others like "statistics", "topicDetails", or "invideoPromotion".
"forUsername=muratashinya" : User / Channel name we are going to retrieve the information piece specified in the part parameter. If we had the Channel ID instead of the user name, it should be specified in the id parameter and not in this one.
"key={YOUR_API_KEY}" : You should fill this parameter with the API key we obtain from the Google APIs console (We will cover this point in the next article) so we can query the Data API URL without restrictions. If you don't specify this parameter, you probably won't be able to query the URL and you will get a "Forbidden" error.

Making a query with these parameters will return us the following information in JSON format, please take a look at the important parts in the lines highlighted:

         "id":"UCwsU7gbEim-JhbgeUvfgLqg",		//ID del canal de youtube
            //Related playlists IDs, the list of videos liked, faved and uploaded by the user
               "likes":"LLwsU7gbEim-JhbgeUvfgLqg",	//Liked
               "favorites":"FLwsU7gbEim-JhbgeUvfgLqg",	//Faved
               "uploads":"UUwsU7gbEim-JhbgeUvfgLqg"	//Uploaded


This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-Share Alike 3.0 Unported License


About the Author

Isaac RF
Software Developer (Senior) Connectis
Spain Spain
Software Developer, 2D/3D Design and game development enthusiast.

Good working on team or alone, very fast learning speed, curious and assertive, always learning new skills.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
JOE MIS15-Apr-15 16:21
memberJOE MIS15-Apr-15 16:21 
GeneralRe: My vote of 5 Pin
Isaac RF16-Apr-15 2:03
professionalIsaac RF16-Apr-15 2:03 
GeneralRe: My vote of 5 Pin
JOE MIS16-Apr-15 18:08
memberJOE MIS16-Apr-15 18:08 
GeneralMy vote of 5! Pin
jediYL9-Apr-15 21:42
professionaljediYL9-Apr-15 21:42 
GeneralRe: My vote of 5! Pin
Isaac RF12-Apr-15 23:30
professionalIsaac RF12-Apr-15 23:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190214.1 | Last Updated 24 Mar 2015
Article Copyright 2015 by Isaac RF
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid